python(字符串魔法以及【range()魔法,for,while循环的应用】input('>>>>'))

test='千万别嘴欠说这11句话'
count=0
while count<len(test):
v=test[count]
print(v)
count=count+1
print('=======')

一、for循环
for 变量名 in 字符串:
print(变量名)
break
continue
for abc in test:
print(abc)

v=range(0,100,5) #range创建连续数字[0到100为区间,5为部长]
for item in v:
print(item)

自己想的一个办法哈哈,,,
test=input('请输入字符') 输出字符串索引/下标
v=len(test)
v1=range(0,len(test))
for item in v1:
print(item,test[item])

正规方法
test=input('请输入字符')
for item in range(0,len(test)):
print(item,test[item])[item])

猜你喜欢

转载自www.cnblogs.com/huohu66888/p/9573339.html
今日推荐