import random
user = int(input("Please enter your number(1 to 6): “))
for num in range(100):
computer = random.randrange(1,7)
if computer!= user:
print(f"The computer value is {computer}”)
print(int(input("Please enter your number again(1 to 6): ")))
elif computer == user:
print(“Congratulations…!”)
print(“You WON the GAME”)
I think you ask why the program doesn’t end after the user has guessed the right number. That is because after the program printed “You WON the GAME” you are still inside the for
loop, so it will just continue. Add a break
after the print and the program will end:
elif computer == user:
print(“Congratulations…!”)
print(“You WON the GAME”)
break