Jan-07-2019, 01:04 AM
UPDATE:
What I wanted to do was this simply:
"Return a value from for loop inside of a function in python"
I wrote a simple testing code to test this append in python as the way I want to achieve with every possibilities to print / return a value, and the result is same that nothing is returning at all...
What I wanted to do was this simply:
"Return a value from for loop inside of a function in python"
I wrote a simple testing code to test this append in python as the way I want to achieve with every possibilities to print / return a value, and the result is same that nothing is returning at all...
#a = [] def append_try(): a = [] for i in range(2): a.append(i) #print(a) return a def main(): b = append_try() if b == "'[0]'": print("0") elif b == "'[1]'": print("1") elif b == "'[0, 1]'": print("2") else: print("it is not working") main()What I got from print is a big "it is not working". Thus, it is not working with append. Is there any other way to do the thing I want ? thank you.