₦airaland Forum

Welcome, Guest: RegisterLoginWith GoogleTrendingRecentNew

Stats: 3,330,580 members, 8,446,118 topics. Date: Thursday, 16 July 2026 at 07:10 AM

Toggle theme

Ektbear's Posts

Nairaland ForumEktbear's ProfileEktbear's Posts

1 2 3 4 5 6 7 8 ... 110 111 112 113 114 115 116 117 118 (of 485 pages)

IslamRe: Nairalanders Iftaar - Season 7 by ektbear: 5:04am On Jul 21, 2012
Jarus is a gem

I like the guy well well
PoliticsRe: Bomb Discovered In Abuja Catholic School by ektbear: 1:33am On Jul 21, 2012
bombing children sad
PoliticsRe: I BELIEVE IN GOODLUCK....! by ektbear: 12:00am On Jul 21, 2012
hustle means hard work
ProgrammingRe: I Need Help With This Python Exercise by ektbear: 11:42pm On Jul 20, 2012
What is the point of this color list, if you'll print out whatever color they enter?


From your description so far, it sounds unnecessary. Just take the string they have, assume that it is a valid color, and call your function that prints it
ProgrammingRe: I Need Help With This Python Exercise by ektbear: 11:15pm On Jul 20, 2012
What do you want to happen if they enter a color that is not in your list?
ProgrammingRe: I Need Help With This Python Exercise by ektbear: 10:36pm On Jul 20, 2012
List comprension loops look like this:


>>> [print('Yay #{0}'.format(i)) for i in range(5)]
Yay #0
Yay #1
Yay #2
Yay #3
Yay #4


(This example doesn't seem to work in Python2 by the way, I get a syntax error. So use Python3).
ProgrammingRe: I Need Help With This Python Exercise by ektbear: 10:33pm On Jul 20, 2012
As you can see, calling the range() function returns a list.

For example, my call range(5) returns the list:

[0,1,2,3,4]

So, to perform a for loop in Python, you can do:

for x in range(5):
do_some_stuff()

In my case, do_some_stuff() is essentially just printing to the screen.

Makes sense?

I do agree with you though, Python list comprehensions seem way cooler to me. I prefer that style of programming to the for loop style in the above image.
ProgrammingRe: I Need Help With This Python Exercise by ektbear: 10:30pm On Jul 20, 2012
Here is a screenshot of my terminal:

https://i45.tinypic.com/nmndrb.jpg
PoliticsRe: Orji Cautions Tinubu Over Remarks by ektbear: 4:36am On Jul 20, 2012
lol
ProgrammingRe: I Need Help With This Python Exercise by ektbear: 8:47pm On Jul 19, 2012
You can use the range() function combined with a for loop (or list comprehension) to reduce the block of print(c) calls down to one line.

Probably also wise to wrap the above in a function. And have the color passed as a parameter to the function.

You can google how to do these things in python (range(), for loop, list comprehension, functions).
PoliticsRe: Sen. Waku Warns Oritsejafor - 'Stop Damaging Our Image Abroad' by ektbear: 7:57am On Jul 19, 2012
Up Oritsejafor
ProgrammingRe: O-O Design Code Smells by ektbear: 7:56am On Jul 19, 2012
"Eww, what is that smell. Your code stank!"
BusinessRe: FG Signs $1.5b Lagos-Ibadan Rail Line Contract by ektbear: 7:54am On Jul 19, 2012
cool
ProgrammingRe: Books On Python by ektbear: 7:52am On Jul 19, 2012
Are you a beginner to programming, or already know another language?

If the latter: http://getpython3.com/diveintopython3/

If the former: http://inventwithpython.com/
ProgrammingRe: I Need Help With This Python Exercise by ektbear: 7:50am On Jul 19, 2012
what if they input blue

what should the output be?

Can you sketch the idea in pseudo-code, or whatever language you know how to use?
PoliticsRe: Fashola Hailed On Security Initiative by ektbear: 7:18am On Jul 19, 2012
fashola swaaag
PoliticsRe: Nigeria On The Brink Of Extinction- Please Read Carefully And Save Nigeria by ektbear: 7:17am On Jul 19, 2012
all things must come to an end
PoliticsRe: Can Nairaland Swing A Presidential Election Result? by ektbear: 7:17am On Jul 19, 2012
no
Nairaland GeneralRe: 70% Of Nairalanders Are Hooligans: Personal Assessment: Agreed? by ektbear: 7:14am On Jul 19, 2012
I am one of the 70%
ProgrammingRe: [Project] 2012 Summer Of Code - WORK HAS COMMENCED by ektbear: 7:05am On Jul 19, 2012
how far along is it? are you guys githubbing it?
RomanceRe: When DNA Proves You Are Not The Father (what Will You Do?) by ektbear: 7:04am On Jul 19, 2012
Hehe grin

Relax guys...i'm just playing around.
RomanceRe: When DNA Proves You Are Not The Father (what Will You Do?) by ektbear: 6:21am On Jul 19, 2012
kill the woman

kill the child

shikena
PoliticsRe: Hillary Clinton Breaks Record As The Most Travelled Diplomat In The World by ektbear: 6:17am On Jul 19, 2012
Heh.

Logging that many miles of travel will tire anyone.

But you are correct. She is certainly less effeminate, weak, and pathetic than certain Nairalanders.
PoliticsRe: Hillary Clinton Breaks Record As The Most Travelled Diplomat In The World by ektbear: 6:02am On Jul 19, 2012
She must be exhausted.
Nairaland GeneralRe: Seun, Shey You Can See That Nairaland Is Dying Quickly by ektbear: 4:32am On Jul 18, 2012
i suspect that seun is making money hand over fist from his adverts

Probably alexa or something will track how much traffic this site has received over time?
ProgrammingRe: Who Can Help With Writing An Encryption Algorithm? How Soon Can One Learn How To by ektbear: 4:31am On Jul 18, 2012
Take a chill pill...no reason to be irritated at either I or the OP. Whether computing is for the OP or not, it certainly won't help him/her to receive incomplete or incorrect information.
PoliticsRe: Attah Igala (Aliyu Obaje) Is Dead by ektbear: 12:46am On Jul 18, 2012
shegzy4luv: I can't imagine wen we shall start having goodnews in dis country,anytime i log in,all i always see is death news,bombings,gun attack,plane crash,tanker explosions,robbery,kidnapping,money ritual,raping etc all in NIGERIA.I NEED GOODNEWS PLS.
So. You were expecting a 102 year old man never to die? grin
Nairaland GeneralRe: Seun, Shey You Can See That Nairaland Is Dying Quickly by ektbear: 10:03pm On Jul 17, 2012
Doesn't seem to be factually true.
RomanceRe: When DNA Proves You Are Not The Father (what Will You Do?) by ektbear: 8:37pm On Jul 17, 2012
Freiburger: What will you do if you find out that you are not the biological father of a child you have been raising for lets assume 20 years?
murder both the woman and the child

just kidding grin

maybe
Foreign AffairsRe: Let's Have Your Questions Here: Ask A Cameroonian? by ektbear: 8:34pm On Jul 17, 2012
nice thread.
PoliticsRe: Is Satan Really A Black Man? by ektbear: 8:33pm On Jul 17, 2012
dayokanu: You mean Jonasathan?
grin
Nairaland GeneralRe: Seun: Request To Free Afam4eva by ektbear: 8:26pm On Jul 17, 2012
meh

pathetic

1 2 3 4 5 6 7 8 ... 110 111 112 113 114 115 116 117 118 (of 485 pages)