+ 1

Simple but Ia stuck, just started coding.

I have a list of 10 numbers, and I need to accept User input (a number from 1 to 10) and replace that number(index location) on the list with an "x" So if you enter 4, it will replace 3 with an x.

26th Feb 2021, 2:56 PM
rezart mersini
5 Answers
+ 1
Here is an example >>> items = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10] num = int(input()) items[num] = "x" print(items)
26th Feb 2021, 6:13 PM
Sonam Tashi
+ 2
rezart mersini Yours code just prints items 10 times... But. Where is the statement for replacing x at index "num"? There is no need loop.. Replace x at index num in list items and print list. try again now..
26th Feb 2021, 3:08 PM
Jayakrishna 🇼🇳
+ 2
items[num]....that was my issue...but got it after Jayakrishna🇼🇳 gave.me the hint....thans for the help
26th Feb 2021, 8:21 PM
rezart mersini
+ 1
Pls Post you try.. Along with the problem with code..
26th Feb 2021, 2:58 PM
Jayakrishna 🇼🇳
0
Sorry. Here it is items = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10] num = int(input()) # your code goes here for i in items: print(items)
26th Feb 2021, 3:01 PM
rezart mersini