calthoff / tstp

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

Chapter 6 challenge 4 #15

Closed mgsosna closed 6 years ago

mgsosna commented 6 years ago

Thanks for writing this book - very helpful. One issue with chapter 6 challenge 4, though:

The book requests ["Where now?", "Who now?", "When now?"].

The solution provided produces ["Where now", "Who now", "When now", ""] instead.

mgsosna commented 6 years ago

This code should work:

our_string = "Where now? Who now? When now?" new_list = our_string.split("?") del new_list[-1]

new_list2 = [item.strip() + "?" for item in new_list] print(new_list2)