assign an existing list to a blank list python -


so i'm trying check if bunch of strings in list called list9000 contain "@" sign. want empty list once has 6 elements, before clearing loop checking elements "@" signs. i've tried using del , other emptying techniques, doesn't seem work. here's work far:

if( len(list9000) == 6):         # print(list9000)         = list9000.count("@")         if(i>1):             amount9000 = amount9000 - + 1             numwrong = numwrong - + 1         list9000[:] = [] list9000.append(line) 

this snippet of code. there 300 lines of other code. reading text file, in add lines of text in file list. if solve problem, done project!

edit: i've tried using del list9000[:], doesn't work.

**update: ** have printed out length of list, , doesn't seem 6 of time, rather increased 6 every time.

you can reassign list9000 new empty list object. careful, python creates reference if assigning mutable objects. simple list9000[:] = [] should job clear list.

if( len(list9000) == 6):     # print(list9000)     = 0     item in list9000:         if("@" in item):             += + 1     if(i>1):         amount9000 = amount9000 - + 1         numwrong = numwrong - + 1     list9000[:] = [] 

Comments

Popular posts from this blog

javascript - RequestAnimationFrame not working when exiting fullscreen switching space on Safari -

Python ctypes access violation with const pointer arguments -