Commit 62747a50 by ligang

01-homework

parents
#!/usr/bin/env python
#-*- coding:utf-8 -*-
def check(s1,s2):
print(sum(map(lambda ch:s1.count(ch),s2)))
def isUnique(str):
l = list(str)
n = len(l)
for i in range(n):
if str.count(l[i]) !=1:
print("J value is repeat,please reinput J values")
exit(0)
def alphaCount(str,type=1):
w = 0
for i in str:
if i.isalpha():
w +=1
if w > 50:
if type==1:
a = 'J'
else:
a ='S'
print("%s alpha gt 50" % a)
exit(0)
def numJwelsInStones(j,s):
if j.strip() =='' or s.strip() == '':
print("J or S values is not empty")
else:
jcount = alphaCount(j,1)
scount = alphaCount(s,2)
isUni = isUnique(j)
chek = check(j,s)
j = input("please input J value" )
S = input("please input S value ")
numJwelsInStones(j,S)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment