Intellipaat Back

Explore Courses Blog Tutorials Interview Questions
0 votes
4 views
in Python by (16.4k points)

I attempted to utilize the python calendar module in version 3.5.2 with: 

import calendar

yy = 2016

mm = 12

# To ask month and year from the user

# yy = int(input("Enter year: "))

# mm = int(input("Enter month: "))

display=calendar.calendar(yy,mm)

# display the calendar

print(display)

be that as it may, each time I attempt to run it crashes and says: 

line 2, in <module>

import calendar

line 4, in <module>

cal = calendar.month(2016, 2)

AttributeError: module 'calendar' has no attribute 'month'

Alternately, I attempted this in terminal (utilizing Python 2.7), and it does what it is told...! 

Simply uncertain why this doesn't work in one of the most recent versions of Python 

1 Answer

0 votes
by (26.4k points)

From this answer here. You likely calling another file called calendar. Utilize this to discover where that document is: print(calendar) Hope this makes a difference! 

EDIT: likewise as indicated by the documentation, I feel that you are searching for the function monthdatescalendar(year, month) not calendar.month(). kindly read over the python3 documentation for calendar. Much appreciated!

Want to become a expert in python? Join the python course fast!

Related questions

0 votes
1 answer
0 votes
1 answer
0 votes
2 answers
0 votes
1 answer

31k questions

32.8k answers

501 comments

693 users

Browse Categories

...