Write a python function to convert a numeric input argument to a string output based on the

following rules:

>=10: A, 9:B, 8:C, 7:D, 6:E, <=5: F

I came up with this, but it does not work at all

table = {'A': 10, 'B': 9, 'C': 8, 'D': 7, 'E': 6, 'F': 5}
choice = raw_input("Please enter a number: ")
for letter, number in table.items():
    if number >= 10:
        print letter

    if number == 9:
        print letter

    if number == 8:
        print letter

    if number == 7:
        print letter

    if number == 6:
        print letter

    if number == 5:
        print letter

Edited 3 Years Ago by pritaeas: Fixed formatting

This should solve the problem, below is the correct way to search a dictionary with a for loop.

def solve():
    dict = {9:'B', 8:'C', 7:'D', 6:'E'}
    choice = raw_input("Please enter a number: ")

    if int(choice) >= 10:
        return 'A'
    elif int(choice) <= 5:
        return 'F'
        for letter in dict:
            if int(choice) == letter:
                return dict[letter]

def main():
    print solve()
if __name__ == '__main__':

^^we got a jokester haha, dude why even waist your time if your not contributing to the thread

This question has already been answered. Start a new discussion instead.