# File: ChapterIOFiles/conversion.py """ File prices.txt is computer $ 3000 printer $ 450 modem $ 15 File (prices.txt)? prices.txt ['computer $ 3000\n', 'printer $ 450\n', 'modem $ 15\n'] computer 2307.69 EU printer 346.15 EU modem 11.54 EU """ def main(): fileName = input( "File (prices.txt)? " ) f = open("Texts/" + fileName, "r" ) lol = f.readlines() #lots of lines in a list of strings- one line one string print(lol) f.close() for i in range( len( lol ) ): line = lol[i] words = line.split() #split 3 words in 3 elements priceUSD = eval( words[2] ) # has the number - price priceEU = round(priceUSD / 1.3, 2) # conversion rate 1.3 lol[i] = words[0] + " " + str(priceEU ) + " EU" # rewrite the line for line in lol: print( line ) main()