Skip to content

Instantly share code, notes, and snippets.

@simon-saliba
Created March 27, 2021 22:31
Show Gist options
  • Save simon-saliba/d0c5272f0f950c6e13769a83abd23fca to your computer and use it in GitHub Desktop.
Save simon-saliba/d0c5272f0f950c6e13769a83abd23fca to your computer and use it in GitHub Desktop.
Pass 4 - Handling a random number of numbers
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