Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialZachary Kaufman
1,463 PointsCan your string be "" and index be ''
This goes for any type of function really, but an example would be string = "Hi I am Zach" string.index('a')
Is this alright, because in index I used ' ' and in the string I used " ". If it works for .index will it work for everything else? I know you can't start a string with ' and end with " but can you have multiple strings, some with ' ' and some with " "?
1 Answer
WAN CHU
8,087 PointsThere are no difference between 'Brabrabra' and "Brabrabra", they are all string, python won't give you error, except you can't use "Brabrabra', one of the purpose of supporting 2 kind's of string notation is to easily include those sentence to string:
- " 6's "
- ' my_string = "" ' You can switch between 'Brabra"bra' and "Brabra'bra" to encode sentence has ' or ".
Zachary Kaufman
1,463 PointsZachary Kaufman
1,463 PointsThanks for your help! I appreciate it.