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")
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")
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)
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.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.