Python Forum
Why this reverse lookup function not working
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Why this reverse lookup function not working
#1
Please, can someone help me explain why this reverse lookup is not working. If I input any of the values in the dictionary, it says not found. Baffled.
mydict = {'a':2, 'b':4, 'c': 5, 'u':98}
#do reverse lookup
v = input('enter a key >')
def reverse_lookup(d, v):
    for keys in d :
        if d[keys] == v :
            print('found')
            return keys
        else :
            print('not found')
            
print(reverse_lookup(mydict, v))
Thanks
Reply


Messages In This Thread
Why this reverse lookup function not working - by Emekadavid - May-31-2020, 05:11 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Reverse Function in Python Voraman 7 3,412 Feb-13-2021, 07:21 PM
Last Post: Voraman
  GUI and function not working together albry 2 2,658 Jan-15-2019, 07:32 AM
Last Post: albry
  Function not working as intended I think? TimeForged 2 3,140 Mar-11-2018, 09:05 AM
Last Post: buran
  [split] Function not working as intended mihshyahoocom 1 2,162 Mar-11-2018, 09:04 AM
Last Post: buran

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020