-1

Hi.I am new to python.I caught a syntax error while executing this code:

a="input("Enter a no.")"
print(type(a))

But if I execute:

a='input("Enter a no.")'
print(type(a))

Or:

a="input('Enter a no.')"
print(type(a))

Then no error occurs can someone explain me this. Thanks in advance.

Ra143
  • 13
  • 3

1 Answers1

1

There is problem with the pairing of inverted commas. When you are using same type of commas twice then the pairing is done with the nearest one. But in second and third version the pairing is done with the type of comma i.e. single inverted comma will be single inverted comma and double will be paired with double. Hope I could explain.