0
How can I save the outputs of this function in a variable? in a list
https://code.sololearn.com/cXj1irYCTNqg/?ref=app This function enters a list with several binary numbers and converts them to decimal numbers, but returns them one below the other. How can I make all decimal numbers to be stored in a variable?
3 Answers
0
We will probably need more work until your code does what you think it does.
But let's start somewhere and go from there. You can follow up with questions.
First thing: Your second line does not work, because you're looping over an iterable that doesn't even exist.
Change line 1 and 2 to this:
def binarioTOdecimal(num_binario):
for i in num_binario:
Now, to store the return value of a function somewhere, you just have to... well, do it.
First you create a list:
some_list = []
Then you append to that list whatever you want to append, in this case the return value of your function call.
some_list.append(binarioTOdecimal('101010'))
For looking at what you got, print it out.
print(some_list)
Even when you add these three lines and run the whole thing, you'll probably not be happy with the result.
Please consider for a while what's going wrong here, then follow up.
+ 1
HonFu Thank you so much!