python小程序2个

1、递归求1-100的和

def sumA(fin):
  if fin==0:
    return 0
  else:
    return fin+sumA(fin-1)

print sumA(100)

 

2、将一个字符串中h字母去掉输出之后的字符串

str1 = 'abcdefghijklmnopqh123'
str2 = []
for i in range(0,len(str1)):
  if str1[i] == 'h':
    continue
  else:
    str2.append(str1[i])


print str2

posted @ 2017-05-11 18:23  joangaga  阅读(143)  评论(0编辑  收藏  举报