Python Forum
Help turning game into function
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Help turning game into function
#1
#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.
Reply


Messages In This Thread
Help turning game into function - by kixxm - Nov-29-2017, 04:35 AM
RE: Help turning game into function - by metulburr - Nov-29-2017, 04:41 AM
RE: Help turning game into function - by micseydel - Nov-29-2017, 07:55 PM
RE: Help turning game into function - by kixxm - Nov-29-2017, 09:14 PM
RE: Help turning game into function - by micseydel - Nov-29-2017, 09:18 PM
RE: Help turning game into function - by kixxm - Nov-29-2017, 09:36 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  TicTacToe Game Add Exception Handling and Warning Function ShaikhShaikh 5 2,460 Nov-03-2021, 05:02 PM
Last Post: deanhystad
  Turning Robot towards goal, comparison of angles SpaceTime 0 2,784 Jan-21-2019, 10:26 PM
Last Post: SpaceTime

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020