访问列表元素-使元素正向和倒向

**#****正向遍历**
word="internationalization"
for i in range(len(word)):
print(word[i],end=" ")

**#反向遍历**
word="internationalization"
for i in range(-1,-(len(word)+1),-1):
print(word[i],end=" ")
**#个人认为第二种要简便和使用!
#正向遍历**
word="internationalization"
word[::]

**# 倒向遍历**
word="internationalization"
word[::-1]

你可能感兴趣的:(python,小程序,概率论)