list and tuple

tuple

1.empty tuple:write nothing inside

tup1 = ()

2.one tuple:remember to print “,”after

tup1 = (‘lu’,)

3.example: tup1[0] means that the first one ofthe tuple, tup2[0:3] means that the first 4 of the tuple

tup1 = (‘lu’, ‘zhi’, ‘zhou’,2019)
tup2 = (1, 2, 3, 4, 5, 6, 7 )
print(tup1[0])
print(tup2[0:3])

list:alomst the same meaning of tuple

list1 = [‘lu’, ‘zhi’, ‘zhou’,2019]
list2 = [1, 2, 3, 4, 5, 6, 7 ]
print(list1[0])
print(list2[0:3])

!!! be care of the brackets

Published by narutolu

I am from Shanghai ,China.My home university is Shanghai univeristy of Finanace and Economics and I am major in economics and taxation. I worked in mckinsey consulting firm, Nielson and Ipsos. My hobby is programming and travelling . I have been to more than 40 countries.

Leave a comment

Design a site like this with WordPress.com
Get started