CS 022A Lecture Notes - Lecture 9: Object Copying, Parsing, Substring

16 views2 pages

Document Summary

We can add one item to a list using append() method or add several items using the extend() method. The append() method is used to add an item to end of a list. The extend() method takes a list as an argument and appends all of the elements. Using append() to populate a list with user data. N = int(input( enter 7 numbers followed by carriage returns )) To add/append multiple elements at the end of a list use, the extend method. The list method extend() adds several elements at the end of an existing list. Extend() behaves like append() but takes a list as an argument. We can separate strings into lists of strings. The list() function takes a string and converts it to a list. A string is a sequence of characters and a list is a sequence of values. Not that a list of characters is not the same as a string.

Get access

Grade+20% off
$8 USD/m$10 USD/m
Billed $96 USD annually
Grade+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
40 Verified Answers
Class+
$8 USD/m
Billed $96 USD annually
Class+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
30 Verified Answers

Related Documents

Related Questions