import random
random_ball = random.sample((1,2,3,4,5,6,7,8,9),3)
strike = 0
ball = 0
while True:
Guess = input ("Please enter three different baseball numbers (1 to 9): ")
if random_ball == guess:
print ("Correct")
break
for i in guess:
if i == random_ball:
if guess.index(i) == random_ball.index(i):
strike += 1
else:
ball += 1
else:
pass
print("strike:{}, ball:{}".format(strike, ball))
Here! Cheer up a little more.
© 2024 OneMinuteCode. All rights reserved.