Python Tuples
Tuples
A tuple is like a list, except you can't change the values in a tuple once it's defined. Tuples are good foo storing information that shouldn't be changed throughout the life of a program. Tuples are designated by parenthesis instead of square brackets. (You can overwrite an entire tuple, but you can't change the individual elements in a tuple.)
A tuple is like a list, except you can't change the values in a tuple once it's defined. Tuples are good foo storing information that shouldn't be changed throughout the life of a program. Tuples are designated by parenthesis instead of square brackets. (You can overwrite an entire tuple, but you can't change the individual elements in a tuple.)
#Defining a tuple dimensions = (800, 600) #looping through a tuple for dimension in dimensions: print (dimension) #Overwriting a tuple dimensions = (800, 600) print(dimensions) dimensions = (1200, 900) print(dimensions)
No comments:
Post a Comment