@mathieuschnd2/

L10.2 Second occurrence-2

Python

No description

fork
loading
Files
  • main.py
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
s = input()
letter = input()

s = s.upper()
letter = letter.upper()

# Chercher la 1ere occurence:
a1ereOcc = s.find(letter)



# Supprimer texte avant occurence:
newS = s[a1ereOcc+1:len(s)]

# Chercher la 1ere ouccrence dans newS
a2emeOcc = newS.find(letter)

if (a1ereOcc == -1):
  print (-2)
elif (a2emeOcc == -1):
  print (-1)
else:
  print (a1ereOcc + a2emeOcc + 1)