1. 程式人生 > >day 03作業答案

day 03作業答案

1.

(10)

name='aleX leNb'
print(name.split('l',1))

(13)

name='aleX leNb'
a=name.replace('a','A')
print(a)

(14)

name='aleX leNb'
count=0
for i in  name:
    if i =='l':
        count+=1
print(count)

(15)

name='aleX leNb'
count=0
for i in  name[0:4]:
    if i =='l':
        count+=1
print
(count)

(16)

name='aleX leNb'
print(name.index('N'))

(17)

name='aleX leNb'
print(name.find('N'))

 

2.

(6)

s='123a4b5c'
print(s[-3::-2])

3.

s='123a4b5c'
for i in  s :
    print(i)

4.

s='123a4b5c'
for i in  range(0,len(s)) :
    print(s+'sb')