Computer Science, asked by ManavSingh485, 1 year ago

Write code to add horseback riding' to the third position (i.E., right before volleyball) in the list sports

Answers

Answered by Anonymous
0

Answer:

Let there is an array of sports name sports. We have instructed to add horseback riding to the third position

Now we know array index starts from zero

Therefore to add an item at the third position it means to add it at the second index.

Therefore the code will be

sports = ['cricket', 'football', 'volleyball', 'badminton', 'hockey', 'chess' 'kabadi', 'basketball', 'curling', 'tennis']

sports.insert(2, 'horseback riding')

Similar questions