Hi guys!
I need your help with a simple program I'm trying to make. It's supposed to read values from a file, covert them (and add/multiply), sort, and then view the values to the user. The values looks like this:
Stockholm
650000
55.5
2100
08 123 456
Whateverstreet 123
...
New York
1250000
39
3500
...
As you might see the values are about apartments. First is the location, second is the price, third is the size, rent, telephone number, and last the address. I've read all the values with
File = open("bo.txt", "r")
List = File.read().split("\n")
The things I want to do is:
First I want to convert some of the values to the type int/float. How can I do this without having to convert each object in the list manually? For example I want to convert the price, size and rent to int/float so I can add and multiply them.
Second I want to calculate the total monthly cost for each apartment. I already have the formula for that but I dont know how to express for instance the price in a good way. Now it's List[2], List[10], List[18] etc... How can i express them differently?
And last, I want to be able to sort the apartments starting with the one with the lowest monthly cost.
I've already done the things above but it's not good programming (the code is really messy and alot longer than it "needs" to be). So I would really appreciate it if you guys could point me in the right direction.
Any ideas?
Thanks!