Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Latest commit

 

History

History
History
40 lines (33 loc) · 1.13 KB

File metadata and controls

40 lines (33 loc) · 1.13 KB
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
shoplist = ["apple", "carrot", "banana", "abc"]
print("item 0 is ", shoplist[0])
print("item 1 is ", shoplist[1])
print("item 2 is ", shoplist[2])
print("item 3 is ", shoplist[3])
print("item -1 is ", shoplist[-1]) #最后一个元素
print("item -2 is ", shoplist[-2]) #倒数第二个
print("item 1 to 3 is", shoplist[1:3]);
print("item 2 to end is", shoplist[2:]);
print("item 1 to -1 is", shoplist[1:-1]);
print("item start to end is", shoplist[:]);
name = "swaroop"
print("characters 1 to 3 is", name[1:3])
print("characters 2 to end is", name[2:])
print("characters 1 to -1 is", name[1:-1])
print("characters start to end is", name[:])
'''
print("i have", len(shoplist), "items to purchase.")
print("This items are:")
for item in shoplist:
print(item)
print ("\nalso have to buy rice.")
shoplist.append("rice2")
print("my shopping list is now", shoplist)
print("i will sort my list now")
shoplist.sort(key=None, reverse=False)
print("my sorted shopping list is now", shoplist)
print("the first item i wil buy is", shoplist[0])
olditem = shoplist[0]
del olditem
print("i bought the", shoplist[0])
print("my shoppint list is now", shoplist)
'''
Morty Proxy This is a proxified and sanitized view of the page, visit original site.