₦airaland Forum

Welcome, Guest: Join Nairaland / LOGIN! / Trending / Recent / New
Stats: 2,188,652 members, 4,772,179 topics. Date: Wednesday, 20 February 2019 at 10:41 PM

Help Me With My Python. - Programming - Nairaland

Nairaland Forum / Science/Technology / Programming / Help Me With My Python. (1743 Views)

My Python Guessing Game... Pythonistas Please Come In / Please Help With My Python Shopping Cart Script / Check Out My Python-kivy Game Hosted On Github... (2) (3) (4)

(1) (Reply) (Go Down)

Help Me With My Python. by BlowJobs: 8:08pm On Jan 26, 2015
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: 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: 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.

2 Likes 1 Share

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): 3:21pm On Jan 28, 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):
return dict(month_days)[month]


that should be enough for you purposes. BlowJobs.

1 Like 1 Share

Re: Help Me With My Python. by Nastydroid(m): 11:18pm On Jan 28, 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
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)

Help On Php/mysql Queue Process / Pls Help Vb: How Bind Data In Href Link / Am Finally Done With My Nairaland Android(unofficial) App.

(Go Up)

Sections: politics (1) business autos (1) jobs (1) career education (1) romance computers phones travel sports fashion health
religion celebs tv-movies music-radio literature webmasters programming techmarket

Links: (0) (1) (2) (3) (4) (5) (6) (7) (8) (9)

Nairaland - Copyright © 2005 - 2019 Oluwaseun Osewa. All rights reserved. See How To Advertise. 60
Disclaimer: Every Nairaland member is solely responsible for anything that he/she posts or uploads on Nairaland.