+ 1

[SOLVED] Why is this Python code not working?

n=int(input()) d=input() for i in range(n) if d in str(i) print(i)

27th Mar 2018, 3:04 AM
Mahesh Kasindi
Mahesh Kasindi - avatar
6 Respuestas
+ 7
The for and if needs colons after them, and the code inside the for and if need to be indented. for i in range(n): if d in str(i): print(i)
27th Mar 2018, 3:06 AM
Tamra
Tamra - avatar
+ 6
Welcome, bro! 😃
27th Mar 2018, 3:16 AM
Tamra
Tamra - avatar
+ 5
You mean indents? Code inside structures like ifs, fors, whiles, and functions/methods in Python needs to be indented. Usually, indents are 4 spaces.
27th Mar 2018, 3:13 AM
Tamra
Tamra - avatar
+ 1
they always need colons?
27th Mar 2018, 3:07 AM
Mahesh Kasindi
Mahesh Kasindi - avatar
+ 1
Can you please tell me about indent?
27th Mar 2018, 3:08 AM
Mahesh Kasindi
Mahesh Kasindi - avatar
+ 1
Thank you bro
27th Mar 2018, 3:16 AM
Mahesh Kasindi
Mahesh Kasindi - avatar