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 trial
yannverreault
12,599 Pointshelp with str.split()
In a Python quiz, they say "The str.split() method can only split on whitespace. (You might need to look at help() for this question.) TRUE/FALSE"
When I look at: >>>help (str.split), I have this: "
split(...)
S.split(sep=None, maxsplit=-1) -> list of strings
Return a list of the words in S, using sep as the
delimiter string. If maxsplit is given, at most maxsplit
splits are done. If sep is not specified or is None, any
"
I still don't know what to answer because the S.split(sep=None, maxsplit=-1) -> list of strings is confusing me. Can anyone explain what is happening? Do I search for the good thing?
Thanks in advance.
1 Answer
Robert Richey
Courses Plus Student 16,352 PointsHi Yann,
The split method can split on any character, but the default is whitespace if nothing is passed in.
"username@example.com".split('@')
# Output: ['username', 'example.com']
Hope this helps,
Cheers