RYB_color = ["Red","Yellow",Blue"] Example 1 Copy_RYB = RYB_color.copy()Example 2 Copy_RYB = list(RYB_color) |
RYB_color = ["Red","Yellow",Blue"] Example 1 RYB_Second = RYB_color.extend(Second_color) Example 2 RYB_Second = RYB_color + Second_color |
RYB_color = list(("Red","Yellow",Blue")) |
|
A tuple is a collection which is ordered and unchangeable. In Python tuples are written with round brackets.
|
RYB_color = ("Red","Yellow","Blue") |
|
Same as access list items. Please check "Access list items" in "Python Lists - Part I" cheat sheet.
|
|
Since tuples are inchangeable, then we cannot change any value. But, we can convert a tuple to a list, change the values that we want within the list and convert the list back into a tuple.
Example `RYB_color = ("Red","Yellow","Blue") |
|
Same as checking item witin a list . Please check "Check if Item Exists" in "Python Lists - Part I" cheat sheet.
|
|
Same as list length. Please check "List Length" in "Python Lists - Part I" cheat sheet.
|
|
Once a tuple is created, we cannot add items to it. Tuples are unchangeable.
|
|
To create a tuple with only one item, we have add a comma after the item, unless Python will not recognize the variable as a tuple.
|
|
Color = ("White",) |
|
Tuples are unchangeable, so we cannot remove items from it, but we can delete the tuple completely.
|
|
RYB_color = ("Red","Yellow","Blue") |
RYB_color = ("Red","Yellow","Blue") |
|
RYB_color = tuple(("Red","Yellow","Blue"))
|
No comments yet.
Cheatography n. The art of mapping complex subjects into clear, instantly navigable reference guides.