Advertisement
Guest User

Untitled

a guest
Jan 23rd, 2019
115
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.44 KB | None | 0 0
  1. CorrectUsername1 = "tombell"
  2. CorrectPassword1 = "tom123654"
  3. score1= 0
  4.  
  5. loop = 'true'
  6. while (loop == 'true'):
  7. username = input("Please enter your username: ")
  8. if (username == CorrectUsername1):
  9. password = input("Please enter your password: ")
  10. if (password == CorrectPassword1):
  11. print ("Logged in successfully welcome" , username)
  12. loop = 'false'
  13. else:
  14. print ("Password incorrect!")
  15. else:
  16. print ("Username incorrect!")
  17. CorrectUsername2 = "ryanyoung"
  18. CorrectPassword2 = "ryanyoung123987"
  19. score2= 0
  20.  
  21. loop = 'true'
  22. while (loop == 'true'):
  23. username = input("Please enter your username: ")
  24. if (username == CorrectUsername2):
  25. password = input("Please enter your password: ")
  26. if (password == CorrectPassword2):
  27. print ("Logged in successfully welcome " , username)
  28. loop = 'false'
  29. else:
  30. print ("sorry Password is incorrect!")
  31. else:
  32. print ("Username incorrect!")
  33. if (password == CorrectPassword2 and username == CorrectUsername2 ):
  34. print("welcome to ryan's dice game")
  35.  
  36. player1score =0
  37. player2score =0
  38. diceroll1 =0
  39. diceroll2 =0
  40.  
  41. for counter in range(0,5):
  42. import random
  43. go = input("player 1 do you wanna roll")
  44. Random_number = random.randint(1,6)
  45. diceroll1= diceroll1 + Random_number
  46. print(diceroll1)
  47. Random_number = random.randint(1,6)
  48. diceroll= diceroll1 + Random_number
  49. print(diceroll1)
  50. if 1== diceroll1%2:
  51. player1score = player1score - 5
  52. print("player1 score is", player1score)
  53. else:
  54. player1score = player1score + 5
  55. print("player1 score is", player1score)
  56.  
  57. go = input("player 2 do you wanna roll")
  58. Random_number = random.randint(1,6)
  59. diceroll2= diceroll2 + Random_number
  60. print(diceroll2)
  61. Random_number = random.randint(1,6)
  62. diceroll2= diceroll2 + Random_number
  63. print(diceroll2)
  64. if 1== diceroll2%2:
  65. player2score = player2score - 5
  66. print("player2 score is", player2score)
  67. else:
  68. player2score = player2score + 5
  69. print("player2 score is", player2score)
  70. if player1score>player2score:
  71. print("player1 you won")
  72. else:
  73. print("player2 you won")
  74.  
  75.  
  76. text_file = open("player1", "a")
  77. text_file.write("player1score")
  78. text_file.write("diceroll1")
  79. text_file.close()
  80. print("File created for player 1.")
  81. text_file = open("player2", "a")
  82. text_file.write("player2score")
  83. text_file.write("diceroll2")
  84. text_file.close()
  85. print("File created for player 2.")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement