Ektbear's Posts
Nairaland Forum › Ektbear's Profile › Ektbear's Posts
1 2 3 4 5 6 7 8 ... 110 111 112 113 114 115 116 117 118 (of 485 pages)
Jarus is a gem I like the guy well well |
bombing children ![]() |
hustle means hard work |
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 |
What do you want to happen if they enter a color that is not in your list? |
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). |
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. |
lol |
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). |
Up Oritsejafor |
"Eww, what is that smell. Your code stank!" |
cool |
Are you a beginner to programming, or already know another language? If the latter: http://getpython3.com/diveintopython3/ If the former: http://inventwithpython.com/ |
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? |
fashola swaaag |
all things must come to an end |
no |
I am one of the 70% |
how far along is it? are you guys githubbing it? |
Hehe ![]() Relax guys...i'm just playing around. |
kill the woman kill the child shikena |
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. |
She must be exhausted. |
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? |
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. |
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? ![]() |
Doesn't seem to be factually true. |
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 ![]() maybe |
nice thread. |
dayokanu: You mean Jonasathan? ![]() |
meh pathetic |
1 2 3 4 5 6 7 8 ... 110 111 112 113 114 115 116 117 118 (of 485 pages)

