Advertisement
Adehumble

Week4 Coding Exercise 14

Feb 22nd, 2020
109
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.90 KB | None | 0 0
  1. #14
  2. print("This program is written to concatenate/join all your inputs with just a space.\nMind you, if your supply an empty value or space(s) as inputs, it's not going to be reflected in the final output.\n Don't mind my epistle. Let's play a game!")
  3. print("|||||"*24)
  4.  
  5. #14
  6. #I am going to be demonstrating the functionality of this code by allowing a any dynamic input from my user
  7.  
  8. #My Function Program
  9. def cleanup(expected_list):
  10.     print(" ".join(expected_list))
  11.  
  12.  
  13.  
  14. #My Main Program
  15. user_string=[]
  16. while True:
  17.     try:
  18.         num=int(input("How many words do u want to play with? "))
  19.         break
  20.     except ValueError:
  21.         print("ooooops! That is a wrong input.\nYou MUST enter a whole number")
  22.         print("|||||"*24)
  23. for n in range(num):
  24.     user_input=input("Enter any word of your choice: ")
  25.     if user_input.count(" ")>=1 or user_input=="" :
  26.         continue
  27.     user_string.append(user_input)
  28.    
  29.  
  30. cleanup(user_string)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement