0
For leaderboard practice thing, I tried a recursive loop thing. What did I do wrong?
n = 1 if n<10: print( n + ".") n = n + 1 That’s what I got. Set n to 1. If n<10, print n and period. Add 1 to n. I keep getting syntax error with the print line. “\.” Didnt do anything (i thought maybe the period is something). Is the app just limiting my ability to use variables at this time?
5 Respuestas
+ 1
The syntax error stems from the fact that you're trying to add/concatenate an integer with a string. But your code has other issues, not least of all the fact that there is no loop.
+ 1
Yimin it should be print(str(n) + ".")
+ 1
There's a colon missing at the end of the first line. The second line needs to be indented.
0
for n in range(1,10):
print(str(n) + “.”)
Would this work?
Thanks Simon!
0
for n in range(1,10):
print( str(n) + ".")
Mistakes colon missing
Print should be indented to for