def main():
import random
# Prompt the use to enter number of times
times = eval(input("Enter number of time you want to play: "))
print("Prize", "\tGuess", "\tView", "\tNewGuess")
# Table layout
for i in range(1, times +1):
print(" ", random.randint(1,3), end = '')
print(" ", random.randint(1,3))
main()
I want each column generate random number from 1 to 3. For "views" colummn, the random number can not be the Prize or guess.(ex when i have prize = 2, guess = 2, my view can only be 1 or 3.)
I realize I didn't assign the variable for random, but when I assign prize = random it give me the coulmn with all same number, what can I do to have different random number in each row.
def main():
import random
# Prompt the use to enter number of times
times = eval(input("Enter number of time you want to play: "))
print("Prize", "\tGuess", "\tView", "\tNewGuess")
# variables
prize = random.randint(1,3)
guess = random.randint(1,3)
# Table layout
for i in range(1, times +1):
print(" ", prize, end = '')
print(" ", guess)
main()

New Topic/Question
Reply



MultiQuote




|