7-42 jmu-python- looking characters (15 points)

A character string input and output position of the first character appears.

Input formats:

  • Line 1: Input string
  • Line 2: Enter a character

Output formats:

  • Find, output corresponding location, format index=X, and  Xindicate find location
  • Could not find output can't find letter XXexpressed Find character

Sample input:

python
t

Sample output:

index=3

Sample input:

python
l

Sample output:

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))

  

Guess you like

Origin www.cnblogs.com/aimilu/p/11819149.html