vendredi 8 novembre 2019

My project python Lottery : condition can't check in list?

i have 3 problem

  1. main question condition can't check number input in list? can't numbercheck == list[1:20] ? how i can check in alllist?

  2. i'm random number for append in loop (1,28) number but sometime in list have 23 number 26 number why 28number? and how i should fix this?

  3. oh last one // can you create code short than me? short work good Lol

code can run but in condition not show

import random
list = []
#i want have random number in list 28 number because reward = 20,5,2,1
#but loop range (1,28) not equal 28
for i in range(1,40):
    r = random.randint(1,100)
    if r not in list:
        list.append(r)

print(list)
#im show list for answer reward (nothing)
#but number input for check condition
numcheck = input("\nSelect number lottery: ")

print("\n#4 reward : ",end='')
for i in list[0:20]:
    print(i,end=' ')

print("\n#3 reward : ",end='')
for j in list[20:25]:
    print(j,end=" ")

print("\n#2 reward : ",end='')
for q in list[25:27]:
    print(q,end=" ")

print("\n#1 reward : ",end='')
for w in list[27:28]:
    print(w,end=" ")

#number check condition not work for list?
if numcheck == list[0:20]:
    print("#4 reward get $100")
elif numcheck == list[20:25]:
    print("#3 reward get $500")
elif numcheck == list[25:27]:
    print("#2 reward get $1,000")
elif numcheck == list[27:28]:
    print("#1 reward get $10,000")




Aucun commentaire:

Enregistrer un commentaire