0

On list

What is the difference b/n this codes Num=[0,1,2,3,4] print = (Num[3]) //and Num = list(range(5)) print = (Num[3])

23rd Mar 2022, 10:19 AM
John
John - avatar
3 Respostas
+ 5
Nothing
23rd Mar 2022, 10:31 AM
Simba
Simba - avatar
+ 3
No difference, but look ... print = ( Num[ 3 ] ) Here you are assigning <Num[ 3 ]>, which is an `int` to a built-in function `print`. This triggers error when you try to call the actual built-in `print` function because it is now an `int`, and an `int` is not a callable object.
23rd Mar 2022, 10:50 AM
Ipang
+ 2
John , the output with print() should be: Num=[0,1,2,3,4] print(Num[3]) #//and Num = list(range(5)) print(Num[3])
23rd Mar 2022, 6:19 PM
Lothar
Lothar - avatar