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
Post a Comment