are these operations on list valid?

Ken ken at hotmail.com
Sat Oct 5 23:11:33 EDT 2002


By the way....same type of question for dictionary.....

Thanks

"Ken" <ken at hotmail.com> wrote in message
news:ano9fi$fo0ko$1 at ID-49758.news.dfncis.de...
> Hi, just like to know if these are valid:
>
> 1:
> Use:
> var1 = "hello"
> var2 = "world"
> list = [var1, var2]
>
> Instead of:
> list = []
> list.append(var1)
> list.append(var2)
> --------------------
> 2.
> Use:
> list=["hello", "world"]
> if list==["hello", "world]: #comparing list with list without examining
> through every element inside
>   do something.....
>
> Instead of:
> list1=["hello", "world"]
> if list[0]==list1[0] and list[1]==list1[1]:
>   do something....
> ---------------------
> Thanks
>
>
>
>





More information about the Python-list mailing list