Create your own help


My code doesnt out put as i expect.. The code outputs as such
not a number
not a number
not a number
not a number
not a number
not a number

why was "a number" not printed?

Replace this line with your code. 
l = ['a','b','c',2,'e','f']
for ele in l:
    if l == 'd':
        print ' a number!'
        print 'not a number'


But it was, six times. Kidding. Can take things too literal, sometimes. Not the output you expected, that I get.

There are some issue with the loop, that's clear, otherwise it would not always be reaching for the else:.

What is l. Well that would be the list, wouldn't it? What is ele? That would be a single element in the list, one item. Getting the picture?

That is only the half of it, though. What are we trying to do here? Identify if an element is numeric?


Ah i see the mistake now, Thank you so much :slight_smile: What a silly mistake


I still do not get what you are trying to do, here. No matter, if you just want to move on, but if you wish to talk about it some more, we're here.


This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.