I wrote s small script to iterate through a dictionary in python3 that works just fine. I was working in a different machine that only had python2.4 installed. I copied the script and ran and now the code is not entering the if-statement within the for loop. I am assuming this is just a version discrepancy.
I had tried to look online to see what some differences could be between versions. Closest I have come to is 'dict.iterkeys()'
tests = {'1':'test1','2':'test2'}
answer = input('which test? ')
for test in tests:
if test == answer:
print(tests[test])
The expected output is for the tests I want to be printed. However, in python version 2.4 it is not entering the if-statement at all. In python3 this script works just fine.
Any insight helps.
Thanks!
test? Put in aprintstatement to trace the values you're checking.testis the variable that will iterate through the dict. I have put in a print statement to track the values. Both inside theforloop and inside theifstatement. That is how I figured out it is not entering theifstatement.answer = int(input('which test? '))on python3