This isn't complex at all. In fact, it's rather helpful.
Both ''
and ""
can be used in python. There's no difference, it's up to you.
In your example, when you type x
, you are given the representation of the string (i.e, it's equivalent to print repr(x)
). It wouldn't have mattered if you did x = 'aa'
I like to use either for cases such as:
print 'Bill said, "Hey!"'
print "I'm coming!"
If we used "
for the first example, then there would be an error because Python would interpret it as "Bill said, "
.
If we used '
for the second example, then there would be an error because Python would interpret it as 'I'
Of course, you could just escape the apostrophes, but beautiful is better than ugly.