print('10 -> 2 [bd], 2 -> 10 [db]')
answ=input('select db or bd : ')
if answ == "db":
a=input('enter a digit')
x=int(a)
list1 = []
while (x):
x%2
x//2
if x==0:
break
I began creating this on python 3.2, but then I had to move on python 2.7.5 and I get the following error message:
Traceback (most recent call last):
File "C:\Users\<file path>", line 3, in <module>
answ=input('select db or bd : ')
File "<string>", line 1, in <module>
NameError: name 'db' is not defined
>>>
I really don't know hat is all about, worked pretty fine on python 3.2 (sorry for my bad english).
In python 2 the equivalent to input
is called raw_input
so line 2 should be answ=raw_input('select db or bd : ')
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.