A Grain of Sand William Blake
To see a world in a grain of sand,
And a heaven in a wild fllower,
Hold infinity in the palm of your hand,
And eternity in an hour.
将上述诗歌以字符串的形式赋值给一个变量,(若使用for循环可不使用索引)利用循环输出上述诗歌,当遇到字母W和w,跳过该字母进入下一次循环,当遇到字母h时,结束输出。(输出时不换行)
输出样例:
A Grain of Sand illiam BlakeTo see a orld in a grain of sand,And a
a='A Grain of Sand William Blake '
'To see a world in a grain of sand,'
'And a heaven in a wild fllower,'
'Hold infinity in the palm of your hand,'
'And eternity in an hour.'
i=0
while i<=100:
if a[i]=='f' or a[i]=='d':
i+=1
continue
elif a[i]=='v':
break
else:
print(a[i],end="")
i+=1
a='A Grain of Sand William Blake'
'To see a world in a grain of sand,'
'And a heaven in a wild fllower,'
'Hold infinity in the palm of your hand,'
'And eternity in an hour.'
for i in (a):
if i=='f' or i=='d':
continue
if i=='v':
break
else:
print(i,end="")