Advertisement
Raulwynn

Untitled

Oct 23rd, 2017
140
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.75 KB | None | 0 0
  1. '''
  2.  
  3. Create a program that asks the user for names, which are written to a file (append?). The program should continue asking for names until the user selects no. Display all names in the file.
  4.  
  5. Next, ask the user for a name; read from the file to determine if that name is already in the file, and display an appropriate message.
  6.  
  7. '''
  8.  
  9. #intro
  10. print("Please enter names. Type STOP to stop adding names.")
  11. print("")
  12.  
  13. #function
  14. with open("file.txt", "a") as write:
  15.     while True:
  16.  
  17.         # input
  18.  
  19.         a = input("\tAdd: ")
  20.         a = a.capitalize()
  21.         if a == "Stop":
  22.             print("")
  23.             print("Names saved successfullly.")
  24.             break
  25.         else:
  26.             write.write(a + "\n")
  27.  
  28. #actions
  29.  
  30.  
  31. #output
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement