-->
当前位置:首页 > 题库

PROGRAMMING:Input string, sort and output the largest character and the index of the character in the original string

Luz5年前 (2021-05-10)题库397
Input string, sort and output the largest character and the index of the character in the original string. The index of the same character takes the maximum value. Tip: implement with tuples.
###Input format:
Enter a string on one line.
###Output format:
Output characters and indexes on one line.
###Input example:
Here is a set of inputs. For example:
```in
Hello Python
```
###Output example:
The corresponding output is given here. There are three spaces between characters and numbers. For example:
```out
y 7
```







answer:If there is no answer, please comment
```
s=input()
lst=[(s[index],index) for index in range(len(s))]
lst.sort()
print(lst[-1][0]," ",lst[-1][1])
```