Pythonis loendi elementide muutmine
Loendi elemente saab muuta samamoodi nagu stringi sümboleid:
pythonlst = [1, 2, 3]
lst[0] = '!'
print(lst) # väljund on ['!', 2, 3]
Задание 1
Antud loend:
pythonlst = [1, 2, 3, 4, 5]
Asendage selle teine element arvuga 10.
Задание 2
Antud loend:
pythonlst = ['a', 'b', 'c', 'd']
Asendage loendi viimane element tõeväärtusega.
Задание 3
Antud loendid:
pythonlst1 = [1, 2, 3]
lst2 = ['a', 'b', 'c']
Asendage loendi lst1 viimane element
loendi lst2 viimase elemendiga. Väljastage
esimene loend konsooli.