calthoff / tstp

This is an old repository for the exercises in "The Self-Taught Programmer." Please see /selftaught.
166 stars 193 forks source link

Issue with chap6_challenge4.py #17

Closed Tico46 closed 6 years ago

Tico46 commented 6 years ago

Instructions (taken from ebook version not sure if text is the same):

  1. Take the string "Where now? Who now? When now?" and call a method that returns a list that looks like: [" Where now?", "Who now?", "When now?"].

Your Solution: lst = "Where now? Who now? When now?".split("?") print(lst)

['Where now', ' Who now', ' When now', '']

This is the second occurrence of this type of problem. You asked for the solution with the '?' but I couldn't figure out a way to do that. Even your solution comes out with the same solution that I came up with. With that being the case, is there a way that you can come up with a solution that can split at ("?" + 1 character)? Splitting at " " will just make a huge list. Thanks!