Welcome!

By registering with us, you'll be able to discuss, share and private message with other members of our community.

SignUp Now!
  • Guest, before posting your code please take these rules into consideration:
    • It is required to use our BBCode feature to display your code. While within the editor click < / > or >_ and place your code within the BB Code prompt. This helps others with finding a solution by making it easier to read and easier to copy.
    • You can also use markdown to share your code. When using markdown your code will be automatically converted to BBCode. For help with markdown check out the markdown guide.
    • Don't share a wall of code. All we want is the problem area, the code related to your issue.


    To learn more about how to use our BBCode feature, please click here.

    Thank you, Code Forum.

Python How to fix beginner project issue (Guess the Number game)

Hi, I'm working on a small game where the computer generates a number, and you have to input (like guess) a random number. Then, the computer will tell you whether the guessed number is too big or too small, or if you guessed it right.

I might not have imported the random number correctly, but the current issue I'm dealing with is SyntaxError. How do I fix my code? Are there any additional problems?

Python:
#im trying to generate a random number here
import random
beg = 1
end = 100
random_integer = random.randint(beg, end)
#apparently there is a syntax error below on the innum == random_integer place but there might be more
input("input a random number")
input = innum
if innum < random_integer:
    print("your number is too small")
elif innum > random_integer:
    print("your number is too big")
else innum == random_integer:
    print("you guessed right")

Thanks.
 
Solution
Hi, I'm working on a small game where the computer generates a number, and you have to input (like guess) a random number. Then, the computer will tell you whether the guessed number is too big or too small, or if you guessed it right.

I might not have imported the random number correctly, but the current issue I'm dealing with is SyntaxError. How do I fix my code? Are there any additional problems?

Python:
#im trying to generate a random number here
import random
beg = 1
end = 100
random_integer = random.randint(beg, end)
#apparently there is a syntax error below on the innum == random_integer place but there might be more
input("input a random number")
input = innum
if innum < random_integer:
    print("your number is too small")...
Hi, I'm working on a small game where the computer generates a number, and you have to input (like guess) a random number. Then, the computer will tell you whether the guessed number is too big or too small, or if you guessed it right.

I might not have imported the random number correctly, but the current issue I'm dealing with is SyntaxError. How do I fix my code? Are there any additional problems?

Python:
#im trying to generate a random number here
import random
beg = 1
end = 100
random_integer = random.randint(beg, end)
#apparently there is a syntax error below on the innum == random_integer place but there might be more
input("input a random number")
input = innum
if innum < random_integer:
    print("your number is too small")
elif innum > random_integer:
    print("your number is too big")
else innum == random_integer:
    print("you guessed right")

Thanks.
Python:
from random import randint

beg = 1
end = 100
random_integer = randint(beg, end)

innum = int(input("input a random number"))

if innum < random_integer:
    print("your number is too small")
elif innum > random_integer:
    print("your number is too big")
else:
    print("you guessed right")
 
Solution

New Threads

Latest posts

Buy us a coffee!

Back
Top Bottom