I am out of trial and error again Lists

Rustom Mody rustompmody at gmail.com
Sat Oct 25 01:27:58 CEST 2014

On Saturday, October 25, 2014 4:30:47 AM UTC+5:30, Seymore4Head wrote:
> On Wed, 22 Oct 2014 16:30:37 -0400, Seymore4Head wrote:
> name="123-xyz-abc" 
> a=range(10)
> b=list(range(10))
> c=str(list(range(10)))
> print ("a",(a))
> print ("b",(b))
> print ("c",(c))
> for x in name:
>     if x in a:
>         print ("a",(x))      
>     if x in b:
>         print ("b",(x))  
>     if x in c:
>         print ("c",(x))
> B is type list and C is type str.
> I guess I am still a little too thick.  I would expect b and c to
> work. 

Lets simplify the problem a bit.
Do all the following in interpreter window

>>> name="012"
>>> b=list(range(3))

>>> for x in name:  print x

>>> for x in b: print x

Same or different?

Now go back to Denis' nice example and put in type(x)
into each print

Same or different?

More information about the Python-list mailing list