Created
February 17, 2020 19:01
-
-
Save mayankdawar/16dc3248c67938ff6dbea5a576c55511 to your computer and use it in GitHub Desktop.
addition_str is a string with a list of numbers separated by the + sign. Write code that uses the accumulation pattern to take the sum of all of the numbers and assigns it to sum_val (an integer). (You should use the .split("+") function to split by "+" and int() to cast to an integer).
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
addition_str = "2+5+10+20" | |
lst = addition_str.split('+') #converting string into list | |
new_lst = [int(i) for i in lst] #converting strings into integer | |
sum_val = sum(new_lst) #Sum of list | |
hadrocodium
commented
Nov 4, 2021
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment