₦airaland Forum

Welcome, Guest: RegisterLoginWith GoogleTrendingRecentNew

Stats: 3,325,024 members, 8,419,982 topics. Date: Thursday, 04 June 2026 at 08:44 AM

Toggle theme

Help Me With My Python. - Programming - Nairaland

Nairaland ForumScience/TechnologyProgrammingHelp Me With My Python. (3268 Views)

1 Reply (Go Down)

Help Me With My Python. by BlowJobs(op):
Hello, guys. i am new to Nairaland.

i need help with my python programming

i am trying to solve this problem, it's my first exercise and i just picked up python like 4 days ago.


month_days= [('January',[31]),('February',[28,29]),('March',[31]), ('April',[30]),('May',[31]),('June',[30]),('July',[31]),('August',[31]),
('September',[30]),('October',[31]),('November',[30]),('December',[31]) ]
day_names = ['Monday','Tuesday','Wednesday','Thursday','Friday','Saturday','Sunday']
Problem 1
Write a function days_in_month which takes a month as an argument and finds the corresponding month in the month_days list and returns the number of days associated with that month.
>>> days_in_month('December')
[31]
>>> days_in_month('February')
[28, 29]

i really don't know how to go about it. i have been reading the ThinkPython for some days now
Thanks
Re: Help Me With My Python. by BlowJobs(op): 8:23pm On Jan 26, 2015
someone there Please
Re: Help Me With My Python. by gottfried21(m): 8:42pm On Jan 26, 2015
BlowJobs:
Hello, guys. i am new to Nairaland. i am from the Namibia

i need help with my python programming

i am trying to solve this problem, it's my first exercise and i just picked up python like 4 days ago.


month_days= [('January',[31]),('February',[28,29]),('March',[31]), ('April',[30]),('May',[31]),('June',[30]),('July',[31]),('August',[31]),
('September',[30]),('October',[31]),('November',[30]),('December',[31]) ]
day_names = ['Monday','Tuesday','Wednesday','Thursday','Friday','Saturday','Sunday']
Problem 1
Write a function days_in_month which takes a month as an argument and finds the corresponding month in the month_days list and returns the number of days associated with that month.
>>> days_in_month('December')
[31]
>>> days_in_month('February')
[28, 29]

i really don't know how to go about it. i have been reading the ThinkPython for some days now
Thanks
Hello fellow Namibian! cheesy
Re: Help Me With My Python. by BlowJobs(op): 9:22pm On Jan 26, 2015
gottfried21:
Hello fellow Namibian! cheesy
Hallo
Wa tokelwapo

do you have a solution to my Python problem?
Re: Help Me With My Python. by gottfried21(m): 10:29pm On Jan 26, 2015
BlowJobs:
Hallo
Wa tokelwapo

do you have a solution to my Python problem?
Unfortunately not my brother,Computer programming is something that I am not that familiar with,Anyways hope that one of the nice people on the forum will help you.Shapshap
Re: Help Me With My Python. by bb6xt(m): 11:42pm On Jan 26, 2015
.
Re: Help Me With My Python. by bb6xt(m): 11:42pm On Jan 26, 2015
month_days= [('January',[31]),('February',[28,29]),('March',[31]), ('April',[30]),('May',[31]),('June',[30]),('July',[31]),('August',[31]),
('September',[30]),('October',[31]),('November',[30]),('December',[31]) ]

def days_in_month(month):
global month_days
return filter(lambda x: x[0] == month, month_days)[0][1]

If you are using Python 3.x remember to add
'from functools import filter' at the top of the file.
Re: Help Me With My Python. by Nobody: 8:11am On Jan 28, 2015
help with your python keh ? make e bite us abi ?
Re: Help Me With My Python. by fattbabakay(m): 10:56am On Jan 28, 2015
bb6xt:
month_days= [('January',[31]),('February',[28,29]),('March',[31]), ('April',[30]),('May',[31]),('June',[30]),('July',[31]),('August',[31]),
('September',[30]),('October',[31]),('November',[30]),('December',[31]) ]

def days_in_month(month):
global month_days
return filter(lambda x: x[0] == month, month_days)[0][1]

If you are using Python 3.x remember to add
'from functools import filter' at the top of the file.
Re: Help Me With My Python. by lordZOUGA(m):
month_days= [('January',[31]),('February',[28,29]),('March',[31]), ('April',[30]),('May',[31]),('June',[30]),('July',[31]),('August',[31]),
('September',[30]),('October',[31]),('November',[30]),('December',[31]) ]

def days_in_month(month):
return dict(month_days)[month]


that should be enough for you purposes. BlowJobs.
Re: Help Me With My Python. by Nastydroid(m):
BlowJobs:
Hello, guys. i am new to Nairaland. i am from the Namibia

i need help with my python programming

i am trying to solve this problem, it's my first exercise and i just picked up python like 4 days ago.


month_days= [('January',[31]),('February',[28,29]),('March',[31]), ('April',[30]),('May',[31]),('June',[30]),('July',[31]),('August',[31]),
('September',[30]),('October',[31]),('November',[30]),('December',[31]) ]
day_names = ['Monday','Tuesday','Wednesday','Thursday','Friday','Saturday','Sunday']
Problem 1
Write a function days_in_month which takes a month as an argument and finds the corresponding month in the month_days list and returns the number of days associated with that month.
>>> days_in_month('December')
[31]
>>> days_in_month('February')
[28, 29]

i really don't know how to go about it. i have been reading the ThinkPython for some days now
Thanks
I will drop an example and you will Use the idea


>>>def name_and_age(name):
Name_and_age={'nastydroid':'17','name:'34','phython':'21'}
Print(name_and_age[name])

>>> name_and_age('python')

Nb:Am using a Mobile phone,
Re: Help Me With My Python. by tinnyailes(m): 1:01pm On Nov 24, 2017
Hello sir pls I really need your help with something important I'd be glad if you could reach me on whatsapp 08176812097 or via my mail msremmurd@gmail.com
1 Reply

My Python Guessing Game... Pythonistas Please Come InPlease Help With My Python Shopping Cart ScriptCheck Out My Python-kivy Game Hosted On Github...234

Java: Which Is Better To Use Jaxb Or StaxHow I Built A Nairaland Web ScraperMason: A Java Json Parser That Works