I Need
['1', '2', '3']
[1, 2, 3]
def chain_a_list_int(p_chain :str):
tab_chain=[] # [str]
tab_int=[] # [int] (list to return)
tab_chain = p_chain.split(",")
tab_chain = [int(i) for i in tab_chain]
tab_int.append(tab_chain)
return tab_int
chain_a_list_int(input("enter the number to conserve: "))
<function chain_a_list_int at 0x000000000349FEA0>
print(chaine_a_liste_entier)
tab_int
print(tab_int)
[1, 2, 3]
That's not an error, but an indication that Python doesn't think that you have asked it to call chain_a_list_int
. The minimal tweak to your code is:
the_list = chain_a_list_int(input("enter the number to conserve: "))
print(the_list)
or
print(chain_a_list_int(input("enter the number to conserve: ")))
A reference to the name of the function chain_a_list_int
, without a (
after it, does not actually cause the function's code to run. This distinction will be useful to you later on — for now, make sure any time you type the name of a function, you put a parenthesized expression after that name. (If @ForceBru posts an answer, you'll see a counterexample :) .)