code not working, can't figure out why
I ran my code in workspaces, apart from saying something is off with tab and indentation, workspace doesn't say where else is wrong.
can anyone gimme a hand? thanks a mil!
def combiner(argu): sum = 0 word = '' for it in argu: if isinstance(it, (int,float)): sum += ''.join(it) elif isinstance(it, str): word += ''.join(it) return word+str(sum)
When you are adding the
it to either variables (sum and word), you don't need to .join() them
- It raises an error anyways as
itis not an iterable like the array they are passing to you,
itwould be things like the strings 'apple' 'dog' or integers like 9 or 7
- The return statement is also inside the for loop just indent it back so it only calls after the for loop is called otherwise it would return after ever loop
These are the changes I made to your code
def combiner(argu): sum = 0 word = '' for it in argu: if isinstance(it, (int,float)): sum += it elif isinstance(it, str): word += it return word+str(sum)