problem!

0 gianmarco . · September 11, 2015
magicNumber = 30 

for n in range(101): 
if n is magicNumber: 
print(n, "this is the magic number") 
break 
else: 
print(n) 


C:\Python34\python.exe C:/Users/Administrator/PycharmProjects/untitled/quinto.py 
File "C:/Users/Administrator/PycharmProjects/untitled/quinto.py", line 5 
print(n, "this is the magic number") 

IndentationError: expected an indented block 

Process finished with exit code 1 

Post a Reply

Replies

Oldest  Newest  Rating
0 Halcyon Abraham Ramirez · September 11, 2015
magicNumber = 30

for n in range(101):
    if n == magicNumber:
        print(n, "this is the magic number")
        break
    else:
        print(n)


it's an indentation error. this outputs it right.

also don't use    is for value comparison read this thread   http://stackoverflow.com/questions/1504717/why-does-comparing-strings-in-python-using-either-or-is-sometimes-produce. use the equality operator ==
  • 1

Python

107,003 followers
About

This section is all about snakes! Just kidding.

Links
Moderators
Bucky Roberts Administrator