New course! Every coder should learn Generative AI!
Try a free lesson+ 2
Why I get different result when I multiply index numbers
nums = [4,7,3,1] for x in nums: print(x * 2) Output 8 14 6 2 nums = [1,2,3] print(nums * 3) Output [1,2,3,1,2,3,1,2,3]
2 Answers
+ 4
In the first case, you are multiplying each number from the list. In the second case you are multiplying to a list of [numbers] and it is repeated several times. Do you need help to fix it?
+ 1
Thank you so much!!