+ 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
2 Antworten
+ 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