New course! Every coder should learn Generative AI!
Try a free lesson- 4
Python
Question: Get five names from the user and store them in a file named “names.txt”
2 Answers
+ 1
Please link your code.
You can get the names using a loop and you'll need to know basic file operations (lessons 46-49 of Python core course)
0
names=[ ]
for i in range(5):
names.append(input ('Name:'))
with open('names.txt','w') as f:
f.write('\n'.join(names))