How I remove whitespace from output..... | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

How I remove whitespace from output.....

https://www.sololearn.com/post/787011/?ref=app

28th Nov 2020, 3:10 PM
Sid
Sid - avatar
8 Answers
+ 7
You also might want to make your code more DRY (Don't Repeat Yourself). Here's one example. months = { "January": "1", "February": "2", "March": "3", "April": "4", "May": "5", "June": "6", "July": "7", "August": "8", "September": "9", "October": "10", "November": "11", "December": "12" } date = input() year = date[len(date)-4:] if "," in date: month = months.get(date[:date.find(" ")]) day = date[date.find(" ")+1:date.find(",")] else: date = date.split("/") month = date[0] day = date[1] print(f"{day}/{month}/{year}")
28th Nov 2020, 3:45 PM
David Ashton
David Ashton - avatar
+ 3
You'll need to correct the spelling of the months too 😉
28th Nov 2020, 3:39 PM
David Ashton
David Ashton - avatar
+ 2
Sid , please make sample for us with input / output data, so that we don't have to guess. Also give us a clear task description. Thanks!
28th Nov 2020, 3:17 PM
Lothar
Lothar - avatar
28th Nov 2020, 3:27 PM
The future is now thanks to science
The future is now thanks to science - avatar
+ 2
Remove the commas from your print statements. They're adding whitespace. Use "+" instead
28th Nov 2020, 3:28 PM
Steven M
Steven M - avatar
+ 2
Just write end="" This might work
30th Nov 2020, 10:48 AM
Krish
Krish - avatar
28th Nov 2020, 3:26 PM
Gordon
Gordon - avatar
0
Plz.. follow the above link.. Which is mentioned in question....
28th Nov 2020, 3:19 PM
Sid
Sid - avatar