I am trying to make a Python Program about the PowerBall. You have 1 red ball (range 1 to 26) and this the random number in the range. You have 5 white balls (range 1 to 69) each unique. I need to create an empty list called whiteBallList. I need to append a string called thisBall to a random number to the whiteBallList. I need to check to see if thisBall is in whiteBallList. If it isn't I need to append thisBall to the whiteBallList. If it is in the list, then I would need to try again. This is what I have so far as to outputting the numbers and getting 1 random red ball.
import random
def main():
numbers = whiteBallList()
print('Your PowerBall Numbers are: ')
print(numbers)
def whiteBallList():
whiteBallList = []
thisBall = random.randint(1, 70)
print('Enter your PowerBall Numbers')
for x in range(5):
thisBall = int(input('Enter a number: '))
whiteBallList.append(thisBall)
redBall = random.sample(range(1,27), 1)
whiteBallList.append(redBall)
return whiteBallList
main()
Aucun commentaire:
Enregistrer un commentaire