mercredi 7 octobre 2020

Lottery code that i have written: when user number = random number, the program still outputs a 'loser' statement

I have started writing a lottery game in which the computer randomly outputs a number and then the user inputs a number, and when these two numbers do not match the computer prints('loser'). But if they do match, then it prints ('winner'). This is all well and good, until i run my code and when the user numbers = the winning numbers, it still for some reason prints out 'loser' Can someone help me with this, i know its an amatuer code but im a semi-begginer. Any help will be well appreciated. Thanks. Code:

import random
import time
r = random
print(30 * '-', 'Lottery Menu', 30 * '-')
print('Play lottery Game: 1')
print('Exit lottery game: 2')
print(74 * '-')
if input() == '1':
  print('You picked to play(1)!')
  f1 = input('enter a number between 1 and 10: ')
  print('your number = ', f1)
  time.sleep(1)
  randint = random.randint(1, 10)
  print('winning number =', randint)
 if f1 == randint:
    print('winner')
 else:
        print('Loser')
else:
print('you exited lottery menu.........')



Aucun commentaire:

Enregistrer un commentaire