輸入一個字符串及字符,輸出第一次出現該字符的位置。
輸入格式:
- 行1:輸入字符串
- 行2:輸入一個字符
輸出格式:
- 找到,輸出對應位置,格式
index=X
的,X
表示查找到位置 - 找不到,輸出
can't find letter X
,X
表示查找字符
輸入樣例:
python
t
輸出樣例:
index=3
輸入樣例:
python
l
輸出樣例:
can't find letter l
s = input() a = str(input()) b = True; count = 0 for e in s: count = count + 1 if e == a: print("index=%d" % count) b = False break if b == True: print("can't find letter {}".format(a))