CSCA20 ° list (range(10,20,2))
Worksheet 4 • [10, 12, 14,16,18]
• Input and output ° If step is omitted, the default is 1
♦ Built-in function input “waits” for the user to ° If x is omitted, the default is 0
enter input. Once the user enters the input, the ° The step can also be negative
value of input() is the string which contains what • Slicing lists
the user entered.
♦ Similar to slicing strings
♦ Example • Aliasing
° name = input (“What is your name?”) ♦ Sometimes we have two variables that are names
• What is your name? Ziren
of the same object; they refer to the same object.
• Name -> Ziren This is called aliasing.
• While loops ♦ Slicing creates a new object.
♦ A while loop allows us to continue looping as
• Nested lists
long as some condition is True. ♦ Lists can contain lists
° while : • Nest loops
♦ Use for loops in a nested lists
° while is a the Python keyword • Aliasing again
° condition is a boolean that must be True to ♦ list = [list1, list2, list3]