Hi I got the following problem, I'm trying to build a program that reads a txt file that contains lines with name of fruits and their respective base prices as the following example:
apple $ 2.00
pearl $ 4.00
guava $ 2.50
and so it goes on.
Yesterday I had some help with people here and I've learned how to make python recognize their prices as a number instead of string, and i was able to multiply their values by one number that was asked to the user. Now I want to make this in a such way that I'm able to take each one of those prices and multiply them for different numbers (one different number for each price) that will be asked for the user to choose.
So far, with the help that I got yesterday I've done this:
print "this program will calculate the total price of the fruits"
y = input('insert a value = ')
with open('fruits.txt') as f:
for line in f:
name, price = line.rstrip().split('$')
price = float(price)
cost = price * (0.76+y)
tcost = cost + price
print name, tcost
Any ideas how to do this?