+ 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.
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)
+ 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..
+ 2
items[num]....that was my issue...but got it after Jayakrishnađźđł gave.me the hint....thans for the help
+ 1
Pls Post you try..
Along with the problem with code..
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)