How to specify a certain range of character in a list of words in list | Sololearn: Learn to code for FREE!
Novo curso! Todo programador deveria aprender IA generativa!
Experimente uma aula grƔtis
+ 1

How to specify a certain range of character in a list of words in list

Ex .. [anna,bob,links] Output if x=2 means last two words in the list of words [na,on,ks]

9th Apr 2019, 5:10 AM
Karthik Devillers
Karthik Devillers - avatar
3 Respostas
+ 2
lst = ["anna", "bob", "links"] print([word[-2:] for word in lst])
9th Apr 2019, 5:46 AM
Diego
Diego - avatar
+ 2
Karthik Devillers, Just giving you a hint, for future reference. You can edit the original question if there was a typo, or need to add/change something. You don't have to write in answers section.
9th Apr 2019, 6:21 AM
Ipang
+ 1
Ob have to come its by mistake..I have typed on
9th Apr 2019, 5:11 AM
Karthik Devillers
Karthik Devillers - avatar