There is an issue with the program when the user correctly guesses the number. The program should end when the break statement executes in the while loop found in main(), but instead it times out.
import random
def main():
level = get_level()
number = generate_random_number(level)
while True:
guess = get_guess()
if check_guess(number, guess) == False:
continue
else:
break
def get_level():
while True:
level = input("Level: ")
try:
int(level)
except ValueError:
continue
if int(level) <= 0:
continue
else:
return int(level)
def generate_random_number(level):
number = random.randint(1, level)
return number
def get_guess():
while True:
guess = input("Guess: ")
try:
int(guess)
except ValueError:
continue
if int(guess) <= 0:
continue
else:
return int(guess)
def check_guess(number, guess):
if guess > number:
print("Too large!")
return False
if guess < number:
print("Too small!")
return False
if guess == number:
print("Just right!")
return True
main()
You sound angry. Take a breath and grow up.
That’s what code reviews feel like. Don’t take it personally. Sugar coating advice is a skill when working in groups.
Evidently i’m not, so got that code review advice the less than tender way.
Everyone one else was not critical and let these avoidable coding mistakes slide. That doesn’t fill me with confidence. Should strive to spend more time testing code bases to eventually be able to see and avoid these kinda coding mistakes.
If anyone feels the need to set me on the road to becoming a lovable teddy bear full of positivity and group comradery, jawboning alone is too kind, feel free to put me in the hot chair by reviewing packages have written and published.
Have ordered the packages according to the value you’d gain by learning them.
logging-strict
wreck
pytest-logging-strict
sphinx-external-toc-strict
drain-swamp and drain-swamp-action