Issue running a working code from Jupytr to Console


#1

When I run this code from the Jupytr it works fine
n = 5
while n > 0 :
print(n)
n = n - 1
print(‘Blastoff!’)

on my command prompt on the console it gives me this error


#2

Hi @RakeshNambiar,

I think you are using Python 2 not Python 3. Are you trying it on CloudxLab?


#3

I am.
I think you are right.
How do I get to a python3 console


#4

Please follow below steps for Python 3

source activate py36
python3

#5

I get the same error


#6

Rakesh ,
Looks like, the Python recognize the print(‘Blastoff!’) is inside the While loop, In that case the in intentation error makes it invalid syntax. So once you are done with your while loop have a blank line to end the while loop, and then have your print(‘Blastoff!’) .

n = 5
x = 10
while n > 0 :
	print(n)
	n = n - 1

print("Blastoff")

#7