Add python files
This commit is contained in:
parent
96aa1f721e
commit
27b5664ae7
7 changed files with 271 additions and 0 deletions
21
thinkcspy/Chapter-10-Exercises/Python-files/Problem11.py
Normal file
21
thinkcspy/Chapter-10-Exercises/Python-files/Problem11.py
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
# Runestone.Academy thinkcspy course
|
||||
# Chapter 10
|
||||
# Problem 11
|
||||
|
||||
def sumUntilEven(lst):
|
||||
# your code here
|
||||
sumlist = 0
|
||||
|
||||
for num in lst:
|
||||
if num % 2 != 0:
|
||||
sumlist += num
|
||||
else:
|
||||
return sumlist
|
||||
|
||||
return sumlist
|
||||
|
||||
mylist = [15, 85, 11, 20, 27, 38, 13]
|
||||
oddlist = [13, 11, 29, 37]
|
||||
|
||||
print(sumUntilEven(mylist))
|
||||
print(sumUntilEven(oddlist))
|
||||
Loading…
Reference in a new issue