''' Purpose: foreshadow dict's Not recommended for large number of mappings ''' import url link = 'http://www.cs.virginia.edu/~cs1112/datasets/csv/romans.csv' roman_mappings = url.get_dictionary( link ) # new url function: get_dictionary() # returns a dictionary from the link reply = input( "Enter a roman numeral: " ) letter = reply.upper() if ( letter in roman_mappings ): # if the letter given by the user is a key in the dictionary roman_mappings # then we get the value from the dictionary conversion = roman_mappings.get( letter ) # get the value of the key letter, whatever string is in the variale # letter else: # else - the letter is not in the dictionary # so set conversion to 'Unknown' conversion = "Unknown" # the variable conversion will take on the value that was set in the if/else statement depending on # which statement was true # if ( letter == "I" ) : # conversion = 1 # elif ( letter == "V" ) : # conversion = 5 # elif ( letter == "X" ) : # conversion = 10 # elif ( letter == "L" ) : # conversion = 50 # elif ( letter == "C" ) : # conversion = 100 # elif ( letter == "D" ) : # conversion = 500 # elif ( letter == "M" ) : # conversion = 1000 # else : # conversion = "Unknown" # print conversion print( conversion )