Python - Coding Bat - List 2

preview_player
Показать описание
Here is my attempt at doing all of List 2

Link to coding bat can be found here:

All the videos, songs, images, and graphics used in the video belong to their respective owners and I or this channel does not claim any right over them. Copyright Disclaimer under section 107 of the Copyright Act of 1976, allowance is made for “fair use” for purposes such as criticism, comment, news reporting, teaching, scholarship, education and research. Fair use is a use permitted by copyright statute that might otherwise be infringing.
Рекомендации по теме
Комментарии
Автор

def sum13(nums):
sum=0
i=0
while i<len(nums):
if nums[i]==13:
nums[i]=0
i+=2
else:
sum+=nums[i]
i+=1
return sum

wongkingshun
Автор

sum = 0
i = 0
while i < len(nums):
if nums[i] == 13:
i += 1 # skip the current 13 and the next number
else:
sum += nums[i]
i += 1
return sum

this code works too

wongkingshun