<pre>def calendar(n, s):
#this will convert string value to a corresponding integer
if s == "Su":
d = 0
elif s == "Mo":
d = 1
elif s == "Tu":
d = 2
elif s == "We":
d = 3
elif s == "Th":
d = 4
elif s == "Fr":
d = 5
elif s == "Sa":
d = 6
print ("Su Mo Tu We Th Fr Sa")
for j in range(d):
print (" ", end = " "),
i = 1
while i <= n:
if i < 10:
print ("",i,end=" "),
else:
print(i,end=" "),
if(i + d) % 7 == 0:
print (" ")
i = i + 1
n = int(input("Input the number of days in the month (28-31): "))
s = input("Input the starting day (Su=Sun, Mo=Mon,...): ")
calendar(n,s)</pre>
Like this:
Like Loading...
Related