🛠️ Scheduled Maintenance | We’ll be undergoing scheduled maintenance and upgrades between 00:00 PST Jan 26th until 00:00 PST Jan 28th. There may be brief interruption of services in that period. We apologize for the inconvenience.

×
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

0
Votes
1
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

 

1 Answer

365 Team
0
Votes

Hi Matt, 
thanks for reaching out and sorry for the delayed response. 
Your option seems in order. If you’d like you can share the results of your approach here in the hub.
 
Best, 
365 Eli