Can anybody tell me why my function won’t work as intended? Whenever I try and run it I am given a syntax error on the function, even though before I got it to run. I also got it to run without the function, but I need it for this project.
My code is this:
def check_guess(guess, number): If guess < number: print”Try higher” Elif guess > number: print”Try lower” Else: print”You got it!”
import random
go_again = 1
While go_again = 1: Minimum = 1 Maximum = int(input(“The minimum is 1. What is the maximum?”)) print(f”The minimum is 1. The maximum is {maximum}.”) Number = random.randint(1, maximum) Guess = int(input(“Enter any number: “)) check_guess({guess}, {number}) print(“Congrats! Took you long enough!”) go_again = input(“Do you want to play again?”) if go_again == “Yes” or go_again == “yes”: go_again = 1 else: Print(“Alright then. Goodbye!”) go_again = 2
submitted by /u/Flat-Watercress-529
[link] [comments]
r/learnpython Can anybody tell me why my function won’t work as intended? Whenever I try and run it I am given a syntax error on the function, even though before I got it to run. I also got it to run without the function, but I need it for this project. My code is this: def check_guess(guess, number): If guess < number: print”Try higher” Elif guess > number: print”Try lower” Else: print”You got it!” import random go_again = 1 While go_again = 1: Minimum = 1 Maximum = int(input(“The minimum is 1. What is the maximum?”)) print(f”The minimum is 1. The maximum is {maximum}.”) Number = random.randint(1, maximum) Guess = int(input(“Enter any number: “)) check_guess({guess}, {number}) print(“Congrats! Took you long enough!”) go_again = input(“Do you want to play again?”) if go_again == “Yes” or go_again == “yes”: go_again = 1 else: Print(“Alright then. Goodbye!”) go_again = 2 submitted by /u/Flat-Watercress-529 [link] [comments]
Can anybody tell me why my function won’t work as intended? Whenever I try and run it I am given a syntax error on the function, even though before I got it to run. I also got it to run without the function, but I need it for this project.
My code is this:
def check_guess(guess, number): If guess < number: print”Try higher” Elif guess > number: print”Try lower” Else: print”You got it!”
import random
go_again = 1
While go_again = 1: Minimum = 1 Maximum = int(input(“The minimum is 1. What is the maximum?”)) print(f”The minimum is 1. The maximum is {maximum}.”) Number = random.randint(1, maximum) Guess = int(input(“Enter any number: “)) check_guess({guess}, {number}) print(“Congrats! Took you long enough!”) go_again = input(“Do you want to play again?”) if go_again == “Yes” or go_again == “yes”: go_again = 1 else: Print(“Alright then. Goodbye!”) go_again = 2
submitted by /u/Flat-Watercress-529
[link] [comments]