+ 1

Expected an indented block

when i do the print command it shows me this error. i have seen it several times but i don't know what this is. help me i want to fix it please. https://code.sololearn.com/ct9Z94gCttMv/?ref=app

3rd Apr 2018, 9:57 PM
Nikos Semertzidis
Nikos Semertzidis - avatar
11 Respostas
+ 2
# Roman Numerals x= int(input("Give a number from 1 to 20")) print("\n") if x==1: print("I") elif x==2: print("II") elif x==3: print("III") elif x==4: print("IV") elif x==5: print("V") elif x==6: print("VI") elif x==7: print("VII") elif x==8: print("VIII") elif x==9: print("IX") elif x==10: print("X") elif x==11: print("XI") elif x==12: print("XII") elif x==13: print("XIII") elif x==14: print("XIV") elif x==15: print("XV") elif x==16: print("XVI") elif x==17: print("XVII") elif x==18: print("XVIII") elif x==19: print("XIX") elif x==20: print("XX") else: print("Your Input Is Incorrect")
4th Apr 2018, 9:26 AM
Emma
+ 4
Indentation isn’t optional in Python. Use Tab or 4 spaces. Like this: if x == 1: print(“I”) else: print(“other”)
3rd Apr 2018, 10:37 PM
Pedro Demingos
Pedro Demingos - avatar
+ 2
I looked through your code, and i think you forgot to mark the end of the lines with a ";" and you might have added an indent to the end of lne 5 without noticing.
3rd Apr 2018, 10:32 PM
Awesomeman 222
Awesomeman 222 - avatar
+ 2
ok, well you can try google. I'm out of ideas.
3rd Apr 2018, 10:37 PM
Awesomeman 222
Awesomeman 222 - avatar
+ 2
You need to ident every piece of code you want in an if or else clause. In your case, every print should be idented.
3rd Apr 2018, 10:37 PM
Emma
+ 2
i am leaving now so c ya tomorrow. thanks for help
3rd Apr 2018, 10:39 PM
Nikos Semertzidis
Nikos Semertzidis - avatar
+ 2
so Xan you are saying that i should add this line print("\n") or i should put it in every line after I or IV
4th Apr 2018, 9:38 AM
Nikos Semertzidis
Nikos Semertzidis - avatar
+ 1
hmmm i dont think so... i did not found any ;
3rd Apr 2018, 10:36 PM
Nikos Semertzidis
Nikos Semertzidis - avatar
+ 1
Changes made: 1) indented all print() functions after elifs and elses 2) added the print("\n") to ensure the output is on a newline. Try commenting the print("\n) out
4th Apr 2018, 9:42 AM
Emma
+ 1
guys i want to thank you. i ended the program
7th Apr 2018, 8:38 AM
Nikos Semertzidis
Nikos Semertzidis - avatar
0
Pedro Demingos i have multiple lines in my code so i added the elif command else-if means elif i think
4th Apr 2018, 9:22 AM
Nikos Semertzidis
Nikos Semertzidis - avatar