Jan-29-2020, 04:29 PM
Hi team,
So I'm writing a simple program that asks for a user input of an integer, and then I need to convert that object into an argument that int() will accept so I can use bin() to retrieve the binary output but nothing I try seems to work. Incoming code:
#user inputs integer
Line 2: numb = input('Enter an integer >')
print(numb)
#numb here is a literal int string bound to the input of numb
numb =(input('Enter it again >' ))
#convert and bind object numb into a str
int(numb)
Line 9: bin1 = bin(numb)
#final output
print(bin1)
At line 9 I get the "builtins.Typeerror:'str' object cannot be interpreted as an integer" even though I thought I converted the object type previously...I'm stumped! I don't understand how the object 'numb' isn't converted into an int since the previous line shows no errors. Any ideas?
So I'm writing a simple program that asks for a user input of an integer, and then I need to convert that object into an argument that int() will accept so I can use bin() to retrieve the binary output but nothing I try seems to work. Incoming code:
#user inputs integer
Line 2: numb = input('Enter an integer >')
print(numb)
#numb here is a literal int string bound to the input of numb
numb =(input('Enter it again >' ))
#convert and bind object numb into a str
int(numb)
Line 9: bin1 = bin(numb)
#final output
print(bin1)
At line 9 I get the "builtins.Typeerror:'str' object cannot be interpreted as an integer" even though I thought I converted the object type previously...I'm stumped! I don't understand how the object 'numb' isn't converted into an int since the previous line shows no errors. Any ideas?