The 365 Data Science team is proud to invite you to our own community forum. A very well built system to support your queries, questions and give the chance to show your knowledge and help others in their path of becoming Data Science specialists.
Ask
Anybody can ask a question
Answer
Anybody can answer
Vote
The best answers are voted up and moderated by our team

Files and Functions Challenge Questions

Files and Functions Challenge Questions

Super Learner
0
Votes
0
Answer

Hello,

  1. How come there is no video @ the end of this section going over the solution to the 6 Questions in this sectio
  2.  Regarding Question 4:

Q4:
1) Create a new file called “capitals.txt” ,
2) store the names of five capital cities in the file on the same line.
THis was # My Humble attempt:
#——————————————–
f = open(‘capitals.txt’,’w’) # Correct
f.write(‘Toronto, Montreal, Vancouver, Calgary, Winnipeg’)
f.close()
f = open(‘capitals.txt’,’r’)
print(f.read())
ACTUAL SOLUTION:
file = open(‘capitals.txt’,’w’)
file.write(‘London, ‘)
file.write(‘Paris, ‘)
file.write(‘Madrid, ‘)
file.write(‘Lisbon, ‘)
file.write(‘Rome,’)
file.close()
f = open(‘capitals.txt’,’r’)
print(f.read())

My Question Q4:  is my method of lumping the 5 capitals into one “f.write()” function a viable alternative…it print on one line 🙂
Regards,

Matt

 

No answers so far.