Oct-01-2020, 03:52 PM
What is your confusion about the code? Are you wondering why boston_celtics[1] returns "jaylen" instead of "kemba"? Python indexing starts at 0, not 1.
Are you wondering what
Are you wondering what
print is a command that writes to standard output. What is written will appear in the terminal from which this program was run. The "%" is a format character. The % inside the quotes is replaced by the value of second_player when the string is printed. This is one of several variants of print formatting. I prefer using f strings which I think are easier to read:
Are you wondering what
boston_celtics = ("kemba", "jaylen", "jayson")
does? The () brackets are a way to create a collection called a tuple. Tuples are like lists (which use [] brackets) but they cannot be modified (append, remove or change items).Are you wondering what
print("The second player in boston is %s" %second_player)
does?print is a command that writes to standard output. What is written will appear in the terminal from which this program was run. The "%" is a format character. The % inside the quotes is replaced by the value of second_player when the string is printed. This is one of several variants of print formatting. I prefer using f strings which I think are easier to read:
print(f'The second player in boston is {second_player}')