mardi 9 novembre 2021

Python- my variable doesn't give me a random number to output in a function (Module = Random)

The output is nothing when i enter all 5 numbers into each input, why is that?I tried all the different ways but i couldn't do it.

Here is my code--

    import random
r1 = random.randint(1, 5)
r2 = random.randint(1, 5)

print(r1, r2)

p1 = [int(input('1 - Enter a number from 1 to 5: ')), 'First Person']
p2 = [int(input('2 - Enter a number from 1 to 5: ')), 'Second Person']
p3 = [int(input('3 - Enter a number from 1 to 5: ')), 'Third Person']
p4 = [int(input('4 - Enter a number from 1 to 5: ')), 'Fourth Person']
p5 = [int(input('5 - Enter a number from 1 to 5: ')), 'Fifth Person']

if p1 == r1 or p1 == r2:
    print('ok')

if p2 == r1 or p2 == r2:
    print('ok')

if p3 == r1 or p3 == r2:
    print('ok')

if p4 == r1 or p4 == r2:
    print('ok')

if p5 == r1 or p5 == r2:
    print('ok')



Aucun commentaire:

Enregistrer un commentaire