Appending to lists in Python -


i trying continually add values list; keeping values there until program exits.

import sha1   def stored_hash(hash):     hashes = []      hash_extend = [hash]     hashes.extend(hash_extend)     return hashes  loop = 1 while loop == 1:     data= raw_input('enter text hash: ')     hash = sha1.run(data)     store = stored_hash(hash)     print store 

i have program called sha1 creates hash of input text. want store hash in list above hashes , able add more each time loop completes list getting larger , larger.

how go this? i'm bit lost why can't append value end of list , print whole list out existing hash values present. @ moment 1 hash value no matter how many times loop completes.

do need make global list?

just pass list in argument:

import sha1  def stored_hash(store, hash):     store.append(hash)  store = [] loop = 1 while loop == 1:     data = raw_input('enter text hash: ')     hash = sha1.run(data)     stored_hash(store, hash)     print store 

Comments

Popular posts from this blog

javascript - Laravel datatable invalid JSON response -

java - Exception in thread "main" org.springframework.context.ApplicationContextException: Unable to start embedded container; -

sql server 2008 - My Sql Code Get An Error Of Msg 245, Level 16, State 1, Line 1 Conversion failed when converting the varchar value '8:45 AM' to data type int -