python Job 1

name = " aleX"

# 1) is removed either side of a value corresponding to the variable name spaces, and outputs the processing result
print(name.strip())

# 2) determines whether the value corresponding to the variable name beginning with "al", and outputs the result

print(name.startswith('al'))

# 3) corresponding to the value of the variable name is determined whether the end of "X", and outputs the result

print(name.endswith('X'))

# 4) corresponding to the value of the variable name in the "l" is replaced with "p", and outputs the result
print(name.replace('l','p'))

# 5) The name of the corresponding variable value in accordance with "l" division, and outputs the result.
print(name.split('l'))

# 6) The name corresponding to the variable value becomes capital, and outputs the result

print(name.upper())

# 7) The name corresponding to the variable value becomes lower case, and the output

print(name.lower())

# 8) Please outputs of the two character values ​​corresponding to the variable name?
print(name[1])

# 9) Make the output value of the first three characters of the name variable corresponding?
print(name[:3])

# 10) Please output value of two characters after variable name corresponding?

print(name[-2:])

# 11) Please name the output value of the variable corresponding to the index where the "e" position?

instead = []
for i,j in enumerate(name):
    if j=='e':
        loc.append(i)
print (place)

# 12) to obtain sequences, removing the last character. Such as: oldboy then get oldbo.
print(name[:-1])

  

Guess you like

Origin www.cnblogs.com/talk-one/p/11080147.html