Oct-02-2017, 01:52 PM
!curl https://raw.githubusercontent.com/MicrosoftLearning/intropython/master/world_temp_mean.csv -o mean_temp.txt the_file = open("mean_temp.txt", "a+") the_file.write("Rio de Janeiro,Brazil,30.0,18.0") the_file.seek(0,0) headings = the_file.readline().strip('\n') headings = headings.split(',') city_temp = the_file.readlines() for line in city_temp: line_list = line.split(',') print(headings[0].title(),"of",line_list[0],headings[2],"is",line_list[2],"Celsius") the_file.close()
Output: % Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 222 100 222 0 0 2349 0 --:--:-- --:--:-- --:--:-- 2387
City of Beijing month ave: highest high is 30.9 Celsius
City of Cairo month ave: highest high is 34.7 Celsius
City of London month ave: highest high is 23.5 Celsius
City of Nairobi month ave: highest high is 26.3 Celsius
City of New York City month ave: highest high is 28.9 Celsius
City of Sydney month ave: highest high is 26.5 Celsius
City of Tokyo month ave: highest high is 30.8 Celsius
City of Rio de Janeiro month ave: highest high is 30.0 Celsius
So this is my code above. The output I produced is correct but my requirement is to use a while loop here."The Weather: use while loop to print city and highest monthly average temp in celsius". can anyone help me with this? thank you!