Remove an item from a list given its index instead of its value: the del statement,insteadstatement,# Unlike the
文章由Byrx.net分享于2019-03-23 06:03:23
Remove an item from a list given its index instead of its value: the del statement,insteadstatement,# Unlike the
# Unlike the pop()) method which returns a value, the del keyword is a statement and # can also be used to remove slices from a list (which we did earlier by assignment # of an empty list to the slice).a = [-1, 1, 66.25, 333, 333, 1234.5]del a[0]print adel a[2:4]print a# del can also be used to delete entire variables:a = [-1, 1, 66.25, 333, 333, 1234.5]del a
相关内容
- Eval function,evalfunction,print eval('
- Generator Expressions,expressions,sum(i*i for
- yield statement: defining a generator function,,yielddefining,def g
- Use int(),useint,rent = int(r
- Join list to a string,joinstring,S = 'spammy'
- A sentence is split up into a list of words,sentencesplit,sentence
- Demonstrates the range() function,demonstratesrange,print 'Count
- str() and repr(): Strings and floating point numbers, have two distin
- Big number,bignumber,print 999999
- Bitwise or,bitwiseor,x = 1
评论关闭