a task have been set create program people pick random numbers lottery , have no clue start.the program must:
- allow players select between 1 - 5 lines.
- 6 number on each line.
- each number must between 1-49.
- and option repeat.
this have far:
lines=int(input("how many lines like?")) in range (0,lines): import random lotterynumbers = [] x = 0 while x < 6: lotterynumbers.append(random.randint(1, 49)) x += 1 lotterynumbers.sort() print (lotterynumbers)
please help.
here, should help:
from random import randint rand_number def create_lotter_numbers(amount=6): return [rand_number(1,49) in range(amount)] def get_user_input(prompt="how many lines like? "): return int(input(prompt))
example of use:
>>> = get_user_input() how many lines like? 5 >>> in range(a): create_lotter_numbers() [47, 22, 4, 7, 41, 16] [12, 30, 36, 1, 39, 10] [7, 19, 7, 13, 1, 17] [5, 26, 9, 49, 32, 22] [32, 30, 5, 34, 45, 6]
about limiting user input, repetition, validity etc... can solve on own. answer here underlying code not faulty have posted.
Comments
Post a Comment