+ 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))
9 Respuestas
+ 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:))
+ 2
nope, same output!
+ 2
What does your function " sorting" return?:)
+ 2
first line 2| 3| 50 | None
second line small| small |big |none
there should be no none at the end
+ 2
thank you ~ swim ~ I fixed as you said, I added return "" to function
+ 1
2 last strings:
print(sorting(oldlist),"\n")
print(sorting(newlist))
Try:
sorting(oldlist)
print("\n")
sorting(newlist)
And it will good or no?