Question:
https://replit.com/@AndrewPS1/pythonFun21909210912
Repl link:
How do you use if statements in python? I tried something from online and it results in a syntax error. I’m not sure why it can’t compare a variable that holds an integer value to a number.
if frog > 30:
print("WOW YOU HAVE A LOT OF FROGS!")
else:
print("Get more frogs :(")
Because in your code frog does not contain an integer, but a string you need to convert:
frog=int(input())
3 Likes
It looks ok, can you post your error? (Are you sure it is a syntax error and not what @fpessolano said?)
And convert back to string for concatenation
1 Like
frog = input("how many frogs do you have?\n")
print("you have " + frog + " frogs")
if int(frog) > 30:
print("WOW YOU HAVE A LOT OF FROGS!")
else:
print("Get more frogs :(")
3 Likes
Or use comma instead of addition and can convert directly on input.
Welcome to replit ask btw @AndrewPS1