+ 1
Adding word
def concatenate(*args): my_list=[] for i in args: new_str= '-'.join(my_list) my_list.append(i) print(new_str) print(concatenate("I", "love", "Python", "!")) #This is my code for the adding word problem, but the output is “I-love-Python” and a “None” in next line,But the expected output is “I-love-Python-!”Can any one help me with this ?
4 Answers
+ 6
Pardis Shahabinejad ,
there may still be the issue that the final exclamation mark will not be printed. see my comments in the attached file.
i also have made a suggsetion how the code can be simplified.
https://code.sololearn.com/cukNV1Fv02qG/?ref=app
+ 4
A function returns `None` when nothing was explicitly returned to the caller. That was why you see `None` in output.
Solution:
Modify concatenate() to return <new_str>
+ 2
Thanks a lot🙏🏼
+ 1
Thanks for your help:)
Hot today
What's wrong? :(
1 Votes
Why won't my image display
0 Votes
I have made a calculator in which my % (Percentage) not work correctly for 100%50 or 100%20.
2 Votes
How the answer is 50?
0 Votes
Number of Ones ( C++ ) question!
1 Votes