I'm going to make a lottery number generator while looking at blogs It's being applied.
import random
num = int (input ("lotto number of games")
print("lotto automatic number".")
print("----------------------")
# Repeat as many games as you entered
for x in range(1, num+1):
lotto = [0, 0, 0, 0, 0]
lotto[0] = random.randrange(1, 71, 1)
lotto[1] = lotto[0]
lotto[2] = lotto[0]
lotto[3] = lotto[0]
lotto[4] = lotto[0]
mega = [0]
mega[0] = random.randint(1, 25)
# Numbering to avoid duplicate numbers
while (lotto[0] == lotto[1]):
lotto[1] = random.randrange(1, 71, 1)
while (lotto[0] == lotto[2] or lotto[1] == lotto[2]):
lotto[2] = random.randrange(1, 71, 1)
while (lotto[0] == lotto[3] or lotto[1] == lotto[3] or lotto[2] == lotto[3]):
lotto[3] = random.randrange(1, 71, 1)
while (lotto[0] == lotto[4] or lotto[1] == lotto[4] or lotto[2] == lotto[4] or lotto[3] == lotto[4]):
lotto[4] = random.randrange(1, 71, 1)
a = lotto[0]
b = lotto[1]
c = lotto[2]
d = lotto[3]
e = lotto[4]
f = mega[0]
g = (a + b + c + d + e + f)
# Sort results
lotto.sort()
# Output Results
if g >= 141 and g <= 220:
print ("Pick number", (lotto))
print ("Mega Ball", (mega))
print(g)
I made this kind of program
if g >= 141 and g <= 220:
print ("Pick number", (lotto))
print ("Mega Ball", (mega))
print(g)
If the total of 141 to 220 is satisfied, I'm trying to print it out on the screen It comes out well when you extract one by one, but when you extract more than two, only the last result is printed out. How should I fix it?
conditional-statement if문
I've just worked on an 18-line code that works well and I'm only sharing some of it. Do the rest yourself.
balls = list(range(1, 45))
random.shuffle(balls)
for _ in range(6):
wins.append(balls.pop())
If (sum(wins) < 140 or sum(wins) > 221): # <-- This is the hint for the total verification you want.
return generate_lotto() # <-- but what? What is this?
© 2024 OneMinuteCode. All rights reserved.