Ana sayfa
/
Teknoloji
/
What will the following code output? my_(-)list=[1,2,3] my_list[1] = 2 print(my list) [1,2,3] [1,20,3] Error [20,2,3]

Soru

What will the following code output?
my_(-)list=[1,2,3]
my_list[1] = 2
print(my list)
[1,2,3]
[1,20,3]
Error
[20,2,3]

What will the following code output? my_(-)list=[1,2,3] my_list[1] = 2 print(my list) [1,2,3] [1,20,3] Error [20,2,3]

Çözüm

4.4120 Voting
avatar
Cenk
Kıdemli · 9 yıl öğretmeni
Uzman doğrulaması

Cevap

The code will output an error. The reason is that the variable name in the second line of the code is incorrect. It should be `my_list` instead of `my_{-}list`. Therefore, the correct code should be:<br />```python<br />my_list = [1, 2, 3]<br />my_list[1] = 2<br />print(my_list)<br />```<br />The output of this code will be:<br />```python<br />[1, 2, 3]<br />```
Derecelendirmek için tıklayın: