0

Why does my python for loop colon get a syntax error?

a=int(input("Enter a number.")
for x in range(a):
    print(" ")
c=int(input("Enter another number.")
for x in range(c):
    print("x")
1
  • 3
    You're not closing off your int function calls... Commented Feb 18, 2017 at 16:03

3 Answers 3

2

This issue is only a missing parenthesis on the input line: a=int(input("Enter a number.") and c=int(input("Enter another number.")

a=int(input("Enter a number."))
for x in range(a):
    print(" ")
c=int(input("Enter another number."))
for x in range(c):
    print("x")
Sign up to request clarification or add additional context in comments.

1 Comment

This is not related to the issue but I will suggest to use xrange and raw_input.
0

There is simple typo in your code, see a,c declarations where you have missed closing one more parenthesis.

a=int(input("Enter a number."))
for x in range(a):
    print(" ")
c=int(input("Enter another number."))
for x in range(c):
    print("x")

Hope that helps.

Comments

0

not_a_robot is right.

Also, in the second loop, you're not even printing the value of the x variable, just an "x".

a=int(input("Enter a number."))
c=int(input("Enter another number."))
...
for x in range(c):
    print(x)

Comments

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.