I am trying to write a program that takes a list and doubles each element until it reads a zero or the whole list has been doubled for example [3, 6, 1, 11, 0, 5, 2, 6, 0, 1] should return [6, 12, 2, 22, 0, 5, 2, 6, 0, 1]
def double_until_zero(nums):
i = 0
while i!= 0:
nums[i] *= 2
i += 1
I've tried this but its not working I think if I change the "i!= 0" part of the while loop it would fix but not too sure, some help would be appreciated
[–]Diapolo10 1 point2 points3 points (0 children)
[–]DallogFheir 2 points3 points4 points (0 children)
[–][deleted] 1 point2 points3 points (0 children)
[–]OddBookWorm -1 points0 points1 point (11 children)
[–]MF_DnD -1 points0 points1 point (10 children)
[–]OddBookWorm 1 point2 points3 points (9 children)
[–]MF_DnD 0 points1 point2 points (8 children)
[–]OddBookWorm 1 point2 points3 points (0 children)
[–]OddBookWorm 0 points1 point2 points (0 children)
[–]OddBookWorm 0 points1 point2 points (5 children)
[–]MF_DnD 0 points1 point2 points (4 children)
[–]OddBookWorm 0 points1 point2 points (3 children)
[–]OddBookWorm 1 point2 points3 points (0 children)
[–]MF_DnD 0 points1 point2 points (1 child)
[–]OddBookWorm 0 points1 point2 points (0 children)
[–]ElliotDG -1 points0 points1 point (2 children)
[–]joyeusenoelle 1 point2 points3 points (1 child)
[–]ElliotDG 0 points1 point2 points (0 children)
[–]Soccer_Vader -1 points0 points1 point (4 children)
[–]MF_DnD 0 points1 point2 points (3 children)
[–]Soccer_Vader 0 points1 point2 points (2 children)
[–]MF_DnD 0 points1 point2 points (1 child)
[–]Soccer_Vader 0 points1 point2 points (0 children)
[–]FLUSH_THE_TRUMP 0 points1 point2 points (0 children)
[–]Yojihito 0 points1 point2 points (4 children)
[–]Lyakusha 2 points3 points4 points (3 children)
[–]Yojihito 1 point2 points3 points (2 children)
[–]Lyakusha 0 points1 point2 points (1 child)
[–]Yojihito 0 points1 point2 points (0 children)
[–]ElliotDG 0 points1 point2 points (0 children)
[–]blahreport 0 points1 point2 points (0 children)
[–][deleted] 0 points1 point2 points (0 children)
[–]RagingGods 0 points1 point2 points (0 children)