23 lines
732 B
Python
23 lines
732 B
Python
|
#!/usr/bin/env python3
|
||
|
# -*- coding: utf-8 -*-
|
||
|
|
||
|
classmates = ['Michael', 'Bob', 'Tracy']
|
||
|
print('classmates =', classmates)
|
||
|
print('len(classmates) =', len(classmates))
|
||
|
print('classmates[0] =', classmates[0])
|
||
|
print('classmates[1] =', classmates[1])
|
||
|
print('classmates[2] =', classmates[2])
|
||
|
print('classmates[-1] =', classmates[-1])
|
||
|
classmates.pop()
|
||
|
print('classmates =', classmates)
|
||
|
|
||
|
classmates = ('Michael', 'Bob', 'Tracy')
|
||
|
print('classmates =', classmates)
|
||
|
print('len(classmates) =', len(classmates))
|
||
|
print('classmates[0] =', classmates[0])
|
||
|
print('classmates[1] =', classmates[1])
|
||
|
print('classmates[2] =', classmates[2])
|
||
|
print('classmates[-1] =', classmates[-1])
|
||
|
|
||
|
# cannot modify tuple: So here will be a error
|
||
|
classmates[0] = 'Adam'
|