0

[SOLVED]Can you assign something to an undefined list index?

For example : Q = input() #number of words is 4 List = Q.split(" ") List[4] = "Bob"

28th Jan 2021, 3:51 PM
Sadra Shakouri
Sadra Shakouri - avatar
4 Antworten
+ 2
Looks like you want to append? List.append("Bob")
28th Jan 2021, 4:02 PM
jtrh
jtrh - avatar
+ 1
I would recommend you to test this yourself by writing code in sololearn playground... This will let you learn yourself... Try it yourself...
28th Jan 2021, 3:54 PM
Steve Sajeev
Steve Sajeev - avatar
+ 1
Swift Ook... I think you got the answer now.. 😊😊
28th Jan 2021, 4:21 PM
Steve Sajeev
Steve Sajeev - avatar
- 1
Steve Sajeev i tried and didnt work, im looking for an alternative solution
28th Jan 2021, 3:55 PM
Sadra Shakouri
Sadra Shakouri - avatar