Nov-29-2017, 04:35 AM
#Make a guess and get feedback.
guess=0
fb=0
while fb != 'c' or fb != 'C':
guess = random.randint(lower, upper)
print("I'm guessing your number is", guess, ". ")
fb=input("Type H if too high, L if too low, or C if correct. ")
if fb == 'l' or fb == 'L':
print("My guess was too low! ")
lower = guess + 1
elif fb == 'h' or fb == 'H':
print("My guess was too high! ")
upper = guess - 1
else:
print("Your entry was invalid. ")
#If guess is correct.
if fb == 'c' or fb == 'C':
print("------------------------------------------")
print("\tHooray! I guessed right! ")
print("------------------------------------------")
I need help turning this entire code above into a function.
sorry about the indentation. It got lost with posting it.
guess=0
fb=0
while fb != 'c' or fb != 'C':
guess = random.randint(lower, upper)
print("I'm guessing your number is", guess, ". ")
fb=input("Type H if too high, L if too low, or C if correct. ")
if fb == 'l' or fb == 'L':
print("My guess was too low! ")
lower = guess + 1
elif fb == 'h' or fb == 'H':
print("My guess was too high! ")
upper = guess - 1
else:
print("Your entry was invalid. ")
#If guess is correct.
if fb == 'c' or fb == 'C':
print("------------------------------------------")
print("\tHooray! I guessed right! ")
print("------------------------------------------")
I need help turning this entire code above into a function.
sorry about the indentation. It got lost with posting it.