cleaning up and organizing old problems (builtin)

This commit is contained in:
Mari Wahl 2015-01-06 20:10:48 -05:00
parent 6afe96fa4d
commit 3fdbc2a605
106 changed files with 480 additions and 1472 deletions

View file

@ -0,0 +1,45 @@
#!/usr/bin/env python
__author__ = "bt3"
def reversing_words(word):
"""
>>> reversing_words('buffy is awesome')
'awesome is buffy'
"""
new_word = []
words = word.split(' ')
for word in words[::-1]:
new_word.append(word)
return " ".join(new_word)
def reversing_words2(s):
"""
>>> reversing_words2('buffy is awesome')
'awesome is buffy'
"""
words = s.split()
return ' '.join(reversed(words))
def reversing_words3(s):
"""
>>> reversing_words('buffy is awesome')
'awesome is buffy'
"""
words = s.split(' ')
words.reverse()
return ' '.join(words)
if __name__ == '__main__':
import doctest
doctest.testmod()