Help on my code > py | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 2

Help on my code > py

Can someone please tell me why code print none at the end of each line and how to delete it? here is a link to my code: #a program to show mapping and sorting on a list def sorting(somelist): for i in somelist: print("{0:5}|".format(i),end="") oldlist=[2,3,15,1,20,-1] newlist=list(map(lambda x:"big" if x>10 else "small",oldlist)) print(sorting(oldlist),"\n") print(sorting(newlist))

15th Oct 2019, 5:28 PM
Shaho Farivar
Shaho Farivar - avatar
7 Answers
+ 3
def sorting(somelist): for i in somelist: print("{0:5}|".format(i),end="") oldlist=[2,3,15,1,20,-1] newlist=list(map(lambda x:"big" if x>10 else "small",oldlist)) sorting(oldlist) print("\n") sorting(newlist) I not see None:))
15th Oct 2019, 6:18 PM
Ivan Ivanov
Ivan Ivanov - avatar
+ 2
nope, same output!
15th Oct 2019, 6:11 PM
Shaho Farivar
Shaho Farivar - avatar
+ 2
What does your function " sorting" return?:)
15th Oct 2019, 6:13 PM
Ivan Ivanov
Ivan Ivanov - avatar
+ 2
first line 2| 3| 50 | None second line small| small |big |none there should be no none at the end
15th Oct 2019, 6:17 PM
Shaho Farivar
Shaho Farivar - avatar
15th Oct 2019, 6:21 PM
Shaho Farivar
Shaho Farivar - avatar
+ 2
thank you ~ swim ~ I fixed as you said, I added return "" to function
15th Oct 2019, 6:25 PM
Shaho Farivar
Shaho Farivar - avatar
+ 1
2 last strings: print(sorting(oldlist),"\n") print(sorting(newlist)) Try: sorting(oldlist) print("\n") sorting(newlist) And it will good or no?
15th Oct 2019, 6:04 PM
Ivan Ivanov
Ivan Ivanov - avatar