1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
Veronika [31]
3 years ago
12

Create a Python program that: Allows the user to enter a person's first name and last name. The user should be able to enter as

many names as they desire. Create a function that takes the first name and last name, puts them together with the last name first, followed by the first name; with the names separated by commas. Take the result from the function, and place the resulting name in a list. Once the user finishes entering names, sort the contents of the list. Write the sorted names from a list into a text file. When you create the text file, allow the user to enter a name for the file to be created. After you finish writing names to the file, close the file and end the program.
Computers and Technology
1 answer:
KIM [24]3 years ago
7 0

Answer:

#main function start

def main():

#list to store names entered by user

name_list=[]

#variable to take input from user to keep rotating the loop and take input from user again and again

ch='y'

fname=""

lname=""

while ch=='y' or ch=='Y':#keep the loop taking input from user till user do not want to enter more

#take input from user

name=[]

fname=input("Enter first name: ")

lname=input("Enter last name: ")

name.append(fname)

name.append(lname)

 

#append the previously input first and last name in main list

name_list.append(name)

ch=input("Do you want to continue: (y/Y for yes)")

#main function end

#get file name from user

filename=input("Enter output file name")

#open file in write mode

file=open(filename,"w")

#keep loop add data in file till main list 'name_list' have

for i in name_list:

#Write data in file

file.write("%s, %s\r\n" % (i[0],i[1]))

#close the file

file.close()

#call main function

main()

Explanation:

input the above code and see output

You might be interested in
Which of the following is true of the 529 plan
sesenic [268]

A 529 Plan is an education savings plan operated by a state or educational institution designed to help families set aside funds for future college costs.

your answer will be: It is a tax-advantaged college savings plan.

5 0
3 years ago
Read 2 more answers
Can someone tell me how to fix the keyboard on ipad?- its in the middle of my screen andd i dont know how to do it
mamaluj [8]

Answer:

Here

Explanation:

To move keyboard to bottom of screen, you just need to tap and hold the keyboard icon at the bottom-right corner of the keyboard, choose Dock option. To fix iPad keyboard in middle of screen, please tap and hold the keyboard icon, then choose Dock.Nov 5, 2020

5 0
3 years ago
A file extension of. Xlsm indicates what type of workbook.
Vitek1552 [10]

We have that the .xlsm <em>Format </em>is used to save Excel Macro-Enabled Workbook file

<h3>Formats</h3>

Generally file are saved in different formats for easy sorting and application on the operating system.

For instance if a music file is renamed and stored in a different format say .exe the audio file wont be recognised as an audio file and hence refuse to play.

e.g

  • .exe for a windows appication
  • ,mp3 for an audio file
  • .xlsm here is used to save Excel Macro-Enabled Workbook file

For more information on Excel visit

brainly.com/question/19295387

8 0
2 years ago
Which question can most help a writer revise an argumentative essay?
Jobisdone [24]
Do details provide support for the claim
7 0
3 years ago
Read 2 more answers
19. Fair use applies to which of the following situations?
MatroZZZ [7]
I think it’s B if not it’s D both are similar
4 0
3 years ago
Other questions:
  • Although the original BBS system was simple, it increased people's ability to communicate
    14·1 answer
  • The acronym is used to define the process that allows multiple devices to share a single routable ip address.
    6·1 answer
  • How can a wiki contribute to an academic paper?
    9·2 answers
  • The objective of an Enterprise Resource Planning (ERP) system is to create a customized software program that integrates the inf
    14·1 answer
  • 5. Why are female fans particularly valuable to the sports industry? Cite two<br> specific reasons.
    11·1 answer
  • The standing toe touch is most likely to result in
    15·1 answer
  • Which principle of design does a designer apply when they create rhythmic movement in a garment by using recurring pleats or det
    13·1 answer
  • To print the number of elements in the array named ar, you can write :
    10·1 answer
  • Match letters from column B to Column A by looking at the picture above.
    11·1 answer
  • Do you need a separate password for each slack channel
    13·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!