I have a loop:
for x in range(0, len(temp)):
if temp[val] == char:
print (" %-9r | %10d | %12s" % (char, frequency, huffmanCode[char]))
val += 1
What it is supposed to do is that char variable should be searched in temp list and if it is found it will be displayed.
For example, if I enter "google" then the output should be:
Character | Frequency | Huffman Code
------------------------------------
'g' | 2 | 0
'o' | 2 | 11
'o' | 2 | 11
'g' | 2 | 0
'l' | 1 | 101
'e' | 1 | 100
But for some reason it does not display anything. How would I search my whole temp list for characters?
temp? Is it a dictionary or list or ...x, you haven't explained whattempis nor what it contains, you haven't told whatvalis. Also in your 'example', "if you enter 'google'" ... enter google where?charthen?