Shows error : "not defined"while using magic function in jupyter

359 Views Asked by At
d = 8.6
print '%1.0f' %(d)

shows error 'd' is not defined

I am using jupyter notebook.

Using the code

print '%1.0f' %(8.6)

gives the correct value. But, it does not recognize 'd' object

1

There are 1 best solutions below

0
Mohammad-Ali Itani On

There is only one possible reason, putting the assignment and the use of variable d on the same line gives an error.

d = 8.6 
print '%1.0f' %(d)

and

print '%1.0f' %(d)

are normally working for me on jupyter notebook!