Python - Why does trying and change "n" rise an exception? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

Python - Why does trying and change "n" rise an exception?

Result is "b2": try: s = ['a','c'] n = [0,2] s[1:1] = 'b' n[1:1] = 1 except: pass print(s[1],n[1])

5th Oct 2019, 10:31 AM
Paolo De Nictolis
Paolo De Nictolis - avatar
1 Answer
+ 2
n [1:1] is an iterable. So right hand side of equation must be an iterable too. 'b' is an iterable so we haven't exception for that.
5th Oct 2019, 10:50 AM
Qasem