Question

PYTHON CODE Given that play_list has been defined to be a list, write an expression that...

PYTHON CODE

Given that play_list has been defined to be a list, write an expression that evaluates to a new list containing the elements at index 0 through index 4 play_list. Do not modify play_list.

0 0
Add a comment Improve this question Transcribed image text
Answer #1

code:

# Define a play_list

play_list = [12, 34, 23, 45, 9, 10, 15,78,54,7]

# Display play_list elements

print('play_list: ', play_list)

# This expression evaluates to a new list

# containing the elements at index 0 through

# index 4 of play_list

new_list = [ play_list[index] for index in range(0, 5) ]

# Display new_list elements

print('new_list: ',new_list)

----------------------

repl.it Untitled 0 ingit Pythun 3.5.2 (default, Det 2815, 13:85:11) IGCC 4.8.21 on Iinux # Dafina a play-list 3 play_list [12

Add a comment
Know the answer?
Add Answer to:
PYTHON CODE Given that play_list has been defined to be a list, write an expression that...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT