0

I'm trying to execute the following code and expected to get the result of the new age. But instead, I got a syntax error. Here is my code:

age = input('Enter your age:')
new_age = int age + 10**2
print(new_age)

And here is the error:

SyntaxError: invalid syntax
1
  • 1
    what does the syntax error point to? Commented Nov 30, 2019 at 22:01

3 Answers 3

2

I'm only a noob, but you need parentheses "()" around the word 'age' in your int statement new_age=int(age)+10**2

Sign up to request clarification or add additional context in comments.

Comments

1

well, if you want to convert age to an int, you do it by:

new_age = int(age) + 10**2

Or better yet:

age = int(input('Enter your age:'))

what you have right now: int age is a SyntaxError

Comments

0

You need to move int:

age = int(input('enter age'))
new_age = age + 10**2
print(new_age)

You can also do as Tomerikoo said:

new_age = int(age) + 10**2

Either one works :)

1 Comment

Rereading. Clarification: int, float, ord, bin, oct, etc. are functions not statements, so you have to have the parenthesis. Sorry for not being clear :/

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.