Advertisement
juanmartinvk

Python Crash Course: Week 4 Graded Assignment ex. 1 bis

Dec 25th, 2019
249
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.66 KB | None | 0 0
  1. def format_address(address_string):
  2.   address_words = address_string.split() #Split into list of words
  3.   house_number = address_words[0] #House number is the first word
  4.   street_name = " ".join(address_words[1:]) #Street name is the remaining words joined by spaces
  5.   return "house number {} on street named {}".format(house_number, street_name)
  6.  
  7. print(format_address("123 Main Street"))
  8. # Should print: "house number 123 on street named Main Street"
  9.  
  10. print(format_address("1001 1st Ave"))
  11. # Should print: "house number 1001 on street named 1st Ave"
  12.  
  13. print(format_address("55 North Center Drive"))
  14. # Should print "house number 55 on street named North Center Drive"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement