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
a. Show the output of the following program: 1: public class Test { 2: public static void main ( String [] args ) { 3: A a = new
faust18 [17]

Answer:

See attached file.

Explanation:

See attached file.

Download txt
3 0
3 years ago
Select the correct answer.
Andrei [34K]

Answer: The answer is C

Explanation: When it comes to research papers your topic shouldnt be too broad. Your topic should be broad enough you can find a good amount of information but not too focused that you can't find any information.

7 0
2 years ago
Which feature of a social news sharing website distinguishes it from a social bookmarking website
Crank
The privacy feature i think
4 0
3 years ago
Read 2 more answers
Which of the following statements is NOT a valid way to create a date object named birthday?
dem82 [27]

Answer:

var birthday = "12/2/1978";

Explanation:

It does not create a date object named birthday because in this statement the birthday is a string which contains 12/2/1978 a date it is not date object it is a string.All other three options are correct way to create a date object.

var birthday = new Date();

creates a date object with the current date and time.

we can also pass date string in the new Date().So var birthday = new Date("12/2/1978"); is also correct.

we can also pass year,month,day in new Date() In this order only.So option fourth is also correct.

4 0
3 years ago
Directions: Asba student of Contact Center Service, you already have an experience using different computer programs. Try to rem
ELEN [110]

Explanation:

can u suggest a title about quarantine

ex: My quarantine life

8 0
2 years ago
Read 2 more answers
Other questions:
  • F we are reduced to a set of computer algorithms, how do we differentiate ourselves from our programming or our connectome? is i
    8·1 answer
  • Unlike a virtual image, a real image
    7·1 answer
  • Can someone help me with...A table can help? PLEASE
    8·1 answer
  • . char values are surrounded by _____ quotes
    15·1 answer
  • What is the rationale behind the development of an operating system in computing?
    15·1 answer
  • A communication medium which allows receivers to observe multiple cues, such as body language and tone of voice, and allows send
    15·1 answer
  • I WILL GIVE BRAINLIEST TO WHO ANSWERS FIRST AND CORRECTLY.
    8·1 answer
  • What is syntax?
    15·1 answer
  • A style sheet consists of CSS ______________________ that specify the layout and format properties to apply to an element. *
    13·1 answer
  • Five varieties of software​
    13·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!