Powering the DeLorean You're the proud new owner of a DeLorean sports car. DeLoreans are best known for being able to travel through time. You can't wait to try it out, you've already started listing all the different times you are going to visit. You have written down the year of each destination in a file called years.txt. However, every time traveller knows that you need plutonium to generate the 1.21 gigawatts of electricity needed. You will need 0.1 grams of plutonium for each year that you travel through. For example, travelling from 2000 to 2011 will take 1.1 grams. Write a program that will work out the total amount of plutonium that you will need to visit each year in years.txt in order, starting in the year 2011. If years.txt contains: 1955 2015 1885 then your program should print out 24.6 grams of plutonium are needed.
Thats the problem
This is my code
myfile=open("years.txt", "rU") (listo) =["2011"] n = 0 t = 0 for line in myfile: listo.append(line.rstrip()) for i in listo: a1 = listo[i] a2 = listo[i+1] t = t + (0.1 * (int(a1) - int(a2))) print t
It isnt working! Someone please help me out!