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
Liono4ka [1.6K]
2 years ago
13

Write a function that takes a list value as an argument and returns a string with all the items separated by a comma and a space

, with and inserted before the last item. For example, passing the previous spam list to the function would return 'apples, bananas, tofu, and cats'. But your function should be able to work with any list value passed to it.
Computers and Technology
1 answer:
Vsevolod [243]2 years ago
4 0

Answer:

The function in Python is as follows:

def myfunction(mylist):

    listitems = ""

    for i in range(len(mylist)):

         if (i < len(mylist)-1):

              listitems = listitems + mylist[i] + ", "

         else:

              listitems = listitems + "and "+mylist[i]

   

    return listitems

Explanation:

This defines the function

def myfunction(mylist):

This initializes an empty string which in the long run, will be used to hold all strings in the list

    listitems = ""

This iterates through the list

    for i in range(len(mylist)):

For list items other than the last item, this separates them with comma (,)

         if (i < len(mylist)-1):

              listitems = listitems + mylist[i] + ", "

For the last item, this separates with and

         else:

              listitems = listitems + "and "+mylist[i]

   

This returns the required string

    return listitems

You might be interested in
Write a machine-language program to add the three numbers 2, –3, and 6 and output the sum on the output device. Write it in a fo
olya-2409 [2.1K]

Answer:

Below is the code ...hope it meet the requirements

lda 0, i

adda 6, i

suba 3, i

adda 2, i

STA 0x0010 ,d

CHARO 0x0010 ,d

.end

Explanation:

8 0
3 years ago
Full form of http.<br>wrong answer will be reported ​
vodomira [7]

Answer:

So it is Hyper Text Transfer Protocol.

Hope it helps

6 0
2 years ago
Read 2 more answers
The packets used to transmit voice on the Internet are similar to the packets that are used to send email. What are some of the
Alona [7]

Answer:

Quality of service (QOS).

Explanation:

In recent computer networking, the convergence of voice, video and text data packet has been made possible. There is no need for a dedicated network for a particular type of packet.

QOS or quality of set is a service rendered to voice or audio packets in VoIP phones to enhance communication.

The email is a digital mailing system that can be used to send all three packets. It enjoys the QOS as voice packets. It is given high preference for transmission and uses the TCP protocol to transmit data reliably.

8 0
2 years ago
Averigua las diferentes intensidades, la potencia total y el gasto en € (de un mes de 30 días con el equipo conectado todo el ti
Naily [24]

<u>Explanation</u>:

<u>Here's what the question entails in clearer detail;</u>

Find out the different intensities, the total power and the cost in € (from a 30-day month with the equipment connected all the time) in the following case: Component Voltage (V) Power (P) CPU 0.95 V 27.97 W RAM 1,257 V 2.96 W Graphics Card 3.28 V 75.3 W HDD 5.02 V 19.3 W Fans 12.02 V 2.48 W Motherboard 3.41 V 18.3 W

7 0
2 years ago
Help me help you............
KiRa [710]

Answer:

change how big or small the shape or sprite is

6 0
1 year ago
Other questions:
  • Does Logarithms and Algorithms same things?
    6·1 answer
  • Please answer this a due tomorrow!!!
    5·1 answer
  • What's a good app that solves trigonometry problems?
    8·1 answer
  • Which route of entry could chemicals use to enter through the body’s airways?
    8·1 answer
  • What are horizontal and vertical page break? how and where are these inserted?​
    10·1 answer
  • This finding maximum number function will keep on going until we reach at the last value
    12·1 answer
  • ______allow you to select elements that are in a certain state, such as when the mouse if hovering over an element
    14·1 answer
  • how risk can impact each of the seven domains of a typical IT infrastructure: User, Workstation, Local Area Network (LAN), Local
    7·1 answer
  • Alfred works in the human resources department, and he uses a management information system to find applicants' résumés on the w
    7·1 answer
  • Taking control of admin functionality and misusing sensitive data that are unauthorized to access are due to.
    8·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!