Does this code can get more shorter | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
29th Dec 2023, 4:06 AM
Neha Agarwal
Neha Agarwal - avatar
5 Answers
+ 2
import calendar print(calendar.calendar(2024)) The problem is this only works on desktop If you run this code on mobile it will be a mess
29th Dec 2023, 5:16 AM
P A Arrchith Iyer
P A Arrchith Iyer - avatar
+ 2
alternative one liner to Mirielle's code: print(*(__import__("calendar").month(2024, i) for i in range(1, 13)))
29th Dec 2023, 11:05 AM
Bob_Li
Bob_Li - avatar
+ 2
Neha Agarwal , Here's the short vanilla version. from calendar import month for m in range(1, 13): print(month(2024, m))
29th Dec 2023, 1:32 PM
Rain
Rain - avatar
+ 2
I found this code on some website, maybe you can benefit from the code: import calendar cal = calendar.TextCalendar(calendar.SUNDAY) print(cal.formatyear(2024, 2, 1, 5, 3))
30th Dec 2023, 10:06 AM
SoloProg
SoloProg - avatar
+ 2
#Addition to the code of P A Arrchith Iyer import calendar as c print(c.calendar(2024, m=1)) #Will work on mobile
30th Dec 2023, 10:14 PM
Louis
Louis - avatar