Using Linked Lists And Patterns In Python
Trying to write a function that will iterate over the linked list, sum up all of the odd numbers and then display the sum. Here is what I have so far: from List import * def main(
Solution 1:
In Python you iterate through a list like this:
list_of_numbers = [1,4,3,7,5,8,3,7,24,23,76]
sum_of_odds = 0
for number in list_of_numbers:
# now you check for odds
if isOdd(number):
sum_of_odds = sum_of_odds + number
print(sum_of_odds)
List
is also a module only on your computer. I do not know what is inside. Therefore, I can not help you after ArrayToList(array)
.
Post a Comment for "Using Linked Lists And Patterns In Python"