- 3
How do i do this question. Fill in the blancks to create a list, reassign the 2 ellment and print the whole list. nums = [33, 42, 56] nums = [ ] =22 print ( )
Can you do this?
8 Réponses
+ 3
nums = [33, 42, 56]
nums[1] = 22
print(nums)
0
0
nums = [33,42,56]
nums[1] = 22
print(nums)
0
nums = [33, 42, 56]
nums[1] = 22
print(nums)
- 1
Lists are accessed by a 0 based index. Meaning the second item in the list is accessed by list[1]
So you would do something like nums[1] = 22
To print the list, just do print(nums)
- 1
nums[1] = 22
print(nums)
- 2
nums = [33, 42, 56]
nums[1] = 22
print(nums)
- 5
What is the result of this code?
nums = [10, 9, 8, 7, 6, 5]
nums[0] = nums[1] - 5
if 4 in nums:
print(nums[3])
else:
print(nums[4])