One: join usage
String iterating to add elements
s='dsfhhewfe' s1='*'.join(s) print(s1)
print result:
d*s*f*h*h*e*w*f*e
Two: String loop (used in conjunction with for loop, you can add break, continue)
1 for loop combined with break
for i in s: if i=='h': break print(i)
print result
2 for loop combined with continue
for i in s: if i=='h': continue print(i)
print result
Three: while and else are used together
while 1: pass else: pass
Four: use for and else together
s='alkshfdfhg' for i in s: if i=='h': continue print(i) else: print('666')
print result