Python


#1

I’m a really BIG newb at Python as I have been coding for like 12 hours in total. But to the point.

Is there two ways you can type a string? For example:

(“This is a test sentence”)

or

‘This is a test sentence’

Would they be the same and work correctly either way? The coding academy doesn’t express that, it’s very frustrating.


#2

there are no official rules, as answered in this question:

most people seem to have a preference, but that is about it

the only thing people agree on is if you want to use quotation marks in string, you use apostrophe to enclose the string:

'mark said: "some very inspirational quote"'

if you would use quotation marks to enclose the string you get:

"mark said: \"some very inspirational quote\""

we have to escape the quotation marks to indicate the string doesn’t end there. It goes without saying which one is preferred

vice versa, the same logic applies. If we need to use apostrophe in our string, we enclose the string with quotation marks


#3

@stetim94 Thank you for the fast and detailed response!


#4

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.