How to get the last letter of a string in Python

2 Answers

0 votes
str = 'Python'

last_char = str[-1]
 
print(last_char)



'''
run:

n

'''

 



answered Nov 3, 2021 by avibootz
0 votes
str = 'Python'

last_char = str[len(str) -1]
 
print(last_char)



'''
run:

n

'''

 



answered Nov 3, 2021 by avibootz
...