topic description
mistakes in doing after-class questions for small turtles
sources of topics and their own ideas
the source is the fifth post-class question for the little soft-shelled turtle.
my idea is to first define a variable, then assign a value to it, and then determine whether the variable is an integer or not. If the input is incorrect and the display is illegal, enter it again. When all the characters entered are numbers, continue to run down. And there are only three chances.
related codes
/ / Please paste the code text below (do not replace the code with pictures)
print("C........................")
import random
secret=random.randint(1,10)
temp=input(":")
count=3
while count:
while not guess.isdigit():
temp=input(":")
guess=int(temp)
if guess==secret:
print("")
break
else:
if guess>secret:
print("",end="")
else:
print("",end="")
count-=1
print("%d:"%count,end=" ")
guess=int(input())
if count==1:
break
if count==1:
print("")
print("%d"%secret,end=" ")
what result do you expect? What is the error message actually seen?
what I expect is that the program runs normally and has three chances to guess numbers. What you actually see is:
File "C:\Users\Desktop\\3.py", line 10
if guess==secret:
^
IndentationError: unexpected indent