Negative Indices numbers: start counting from the right,indicescounting,word = 'Hell
Negative Indices numbers: start counting from the right,indicescounting,word = 'Hell
word = 'Hello world'print word[-1] # The last characterprint word[-2] # The last-but-one characterprint word[-2:] # The last two charactersprint word[:-2] # Everything except the last two characters
相关内容
- Use lambda to define inner function,lambdainner,def func():
- lambda function definition with default value,lambdadefinition,x =
- The dir Function,thedirfunction,#dir returns
- in can be applied to any 'iterable' object,appliedi
- Convert string to a list and add them together,convertstring,print
- Use map,usemap,print pow(3,
- iter: Iterator Types,iteriteratortypes,D = {'a':1,
- Reduce: lambda function inside,reducelambda,foo = [2, 18
- Functional Programming Tools: reduce,,# 'reduce(fu
- Loop over a sequence in reverse,sequencereverse,# Loop over
评论关闭