""" If every character appears more than once, return -1. Example input: s: "Who wants hot watermelon?
. output: 8
."""
def findLastIndex(str, x):
index = -1
for i in range(0, len(str)):
if str[i] == x:
index = i
return index
# String in which char is to be found
str = "Who wants hot watermelon"
# char whose index is to be found
x = 's'
index = findLastIndex(str, x)
if index == -1:
print("Character not found")
else:
print(index)