I have the following list:
item = [['01jan.jpg', 'Cluny', 'Tres Riches Heures', 'January'],
['02feb.jpg', 'Cluny', 'Tres Riches Heures', 'February']]
and want to extract the first entry and change the .jpg
to .png
:
x = item[0][0] print(x) # gives '01jan.jpg'
y = slice(x[:-4]) print(y) # gives 'slice(None, '01jan', None)'
and I can't get the middle term out because slice object is not iterable.
How do I get '01jan'
as a variable? Other items have varying names but all have the same .jpg
so I want to slice off the back of the first item.