Assigning to a slice
Predict the outputMediumPython only
a = [0, 1, 2, 3, 4]
a[1:3] = [9]
print(a)
print(a[-1], a[::2])
a[:0] = [-1]
print(a)
This question is part of Pro+
Pro+ opens every question in Interview Prep and the mock interview. Every article and the first 2 questions of each topic stay free. Hands-on Selenium and API tasks follow their course lesson's own lock.