Created
March 27, 2021 22:31
-
-
Save simon-saliba/d0c5272f0f950c6e13769a83abd23fca to your computer and use it in GitHub Desktop.
Pass 4 - Handling a random number of numbers
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
def add(str): | |
if(len(str) == 0) : return 0 | |
else: | |
numbers_str = [] | |
# Split string by comma | |
numbers_comma_split = str.split(',') | |
sum_result = 0 | |
for i in range(len(numbers_comma_split)): | |
sum_result = sum_result + numbers_comma_split[i] | |
return sum_result |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment