Python appending a list to a list and then clearing it -


i have part of code isolated testing purposes , question

notasks = int(input()) nooutput = int(input()) outputclist = [] outputclist = []  in range(0, notasks):     w in range(0, nooutput):         outputchecked = str(input())         outputclist.append(outputchecked)     outputclist.append(outputclist)     outputclist[:] = [] print(outputclist) 

i have code here, , output

[[], []] 

i can't figure out how following output, , must clear sublist or wrong...

[["test lol", "here can more stuff"], ["test 2 lol", "here can more stuff"]] 

in python object. list object elements. create 1 object outputclist filling , clearing contents. in end, have 1 list multiple times in outputclist, , last thing clearing list, list empty.

instead, have create new list every task:

notasks = int(input()) nooutput = int(input()) output = []  in range(notasks):     checks = []     w in range(nooutput):         checks.append(input())     output.append(checks) print(output) 

Comments

Popular posts from this blog

twig - Using Twigbridge in a Laravel 5.1 Package -

jdbc - Not able to establish database connection in eclipse -

firemonkey - How do I make a beep sound in Android using Delphi and the API? -