Advertisement
Guest User

Untitled

a guest
Oct 18th, 2018
98
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.81 KB | None | 0 0
  1. import random
  2.  
  3. def signup(): #this creates the function called signup.
  4.  
  5. username = "Jack" #sets the variable "Jack" as the username.
  6. password = "password1" #sets the variable "password1" as the password.
  7.  
  8. username1 = str(input("What is the username? ")) #asks for the username
  9. password1 = str(input("What is the password? ")) #asks for the password
  10.  
  11. if username1 == username and password == password1: #if the U and P are correct it prints "Welcome to the program"
  12. print ("Welcome to the program!")
  13. elif username1 and password1: #when it is wrong it repeats the function.
  14. print ("Incorrect Username or Password.")
  15. print ("Please try again...")
  16. signup()
  17.  
  18. def mainMenu():
  19.  
  20. print (" 1) Option 1")
  21. print (" 2) Option 2")
  22. print (" 3) Option 3")
  23.  
  24. opt = int(input("Enter your choice: "))
  25.  
  26. while opt >= 4:
  27. print ("That is not a valid option. Please try again...")
  28. opt = int(input("Enter your choice: "))
  29. if opt == (1):
  30. print ("You have chosen option 1! ")
  31. rand()
  32. mainMenu()
  33. elif opt == (2):
  34. print ("You have chosen option 2! ")
  35. elif opt == (3):
  36. print ("You have chosen option 3! ")
  37.  
  38.  
  39.  
  40. def rand():
  41. ListName = []
  42. file = open("songs.txt", "r")
  43. for line in file:
  44. ListName.append(line)
  45. file.close()
  46.  
  47.  
  48.  
  49.  
  50.  
  51.  
  52.  
  53. #Fluff at the bottom
  54. signup() #adding this makes it so you dont have to type in "signup()" at the beginning.
  55. mainMenu() #adding this makes it so you dont have to type in "mainMenu()" at the beginning.
  56.  
  57.  
  58.  
  59. '''def rand():
  60. lines = open('songs.txt').read().splitlines()
  61. myline =random.choice(lines)
  62. song = myline
  63. songselect = song[:1]
  64. print (songselect)'''
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement