Operation and maintenance program written questions

First, the Python language to the list [1,3,5,7,9] and reverse elements into a character type, please write a number of ways:

the first method:

list = [1, 3, 5, 7, 9]
list.reverse()
list2 = [str(i) for i in list]
print(list2)

The second method:

list = [1, 3, 5, 7, 9]
list2 = list[::-1]
list3 = [str(i) for i in list2]
print(list3)

Two, Python achieve, given a string, the string found in a repeat of the first character. The input "Hello Duoyi", the output "l"

INPUT = A ( " Enter a string: " ) 
B = len (A)
 for I in Range (0, B): 
    C = a.count (A [I])   # statistics appear in the list an element of frequency 
    IF C == 2 :
         Print (A [I])
         BREAK

 

Guess you like

Origin www.cnblogs.com/opsprobe/p/11588507.html