Reputation: 11
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")
Upvotes: 0
Views: 10386
Reputation: 416
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)
Upvotes: 0
Reputation: 705
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.
Upvotes: 0
Reputation: 523
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")
Upvotes: 2