nux tools rely on it.
Alan Gauld
Author of the Learn To Program website
http://www.alan-g.me.uk/
http://www.flickr.com/photos/alangauldphotos
>Original message
>From : stefan.sthila...@gmail.com
>Date : 02/10/2014 - 00:30 (BST)
>To : alan.ga...@btinternet.com
>Subject : Re: [Tut
Stefan St-Hilaire wrote:
> Hello, I am just starting out with Python and ran into a problem
> day one. I am doing this statement:
>
> input("\n\nPress the enter key to exit.")
>
> I get the following error:
>
> >>> input("\n\nPress the enter key to exit.")
>
>
> Press the enter key to e
On 01/10/14 22:34, Stefan St-Hilaire wrote:
>>> input("\n\nPress the enter key to exit.")
Press the enter key to exit.
Traceback (most recent call last):
File "", line 1, in
File "", line 0
^
SyntaxError: unexpected EOF while parsing
I am using Linux (Shell) and PyCharm and get
Hello, I am just starting out with Python and ran into a problem
day one. I am doing this statement:
input("\n\nPress the enter key to exit.")
I get the following error:
>>> input("\n\nPress the enter key to exit.")
Press the enter key to exit.
Traceback (most recent call last):
File "
> I see I have to do a loop inside a loop and that this the right expression
> if word == 'ar' or word == 'ko':
>
> but this is not:
> if word == 'ar' or 'ko':
In the last example: as the 'or' operator has the least priority, it
will be applied last. Which means that all other operations in the
if 'ar' or 'ko' in item:
This is incorrect. What you meant to say was:
if 'ar' in item or 'ko' in item:
or something equivalent to that.
"if 'ar' or 'ko' in item" means "if ('ar') is True or ('ko' in item) is
True". Since 'ar' is True anyway, you'll get a match every time.
__
> list1 = ['ar', 'fir', 'wo']
> list2 = ['ber', 'gar', 'gt']
> list3 = ['hu', 'mo', 'ko', 'tr']
> list4 = ['q', 'wer', 'duh']
>
> whole = [list1, list2, list3, list4]
> for item in whole:
>if 'ar' or 'ko' in item:
>print item
>
> So, the unexpected result was that I got all lists printe
Wesley wrote:
On Mon, Dec 22, 2008 at 1:19 PM, wesley chun wrote:
>
> in addition, i think (and i may be wrong about this) that he really
> wanted to do:
>
> if 'arr' in list1 or 'bell' in list1...
>
Thanks for all the replies. Yes that was actually what I meant. My
mistake too was that I gave y
Le lundi 22 décembre 2008 à 11:33 -0700, Eduardo Vieira a écrit :
> Hello, I'm trying to teach my self programming with python and there
> are some basic things that stumps me:
> Given this code:
> ###
> list1 = ['arr', 'bre', 'grau', 'lower', 'tudo']
> for item in list1:
> if 'arr' in item:
>
>> if 'arr' or 'bell' in item:
>
> The interpreter sees this as
> if ('arr') or ('bell' in item):
>
> 'arr' always evaluates to True so the condition is always true. The
> correct way to express this condition is
> if 'arr' in item or 'bell' in item:
arrgh. yes, i saw this too but forgot to ment
On Mon, Dec 22, 2008 at 1:33 PM, Eduardo Vieira wrote:
> if 'arr' or 'bell' in item:
The interpreter sees this as
if ('arr') or ('bell' in item):
'arr' always evaluates to True so the condition is always true. The
correct way to express this condition is
if 'arr' in item or 'bell' in item:
eduardo,
welcome to programming, and even better, welcome to Python! you've
done your research and found a list of great people who can help you
out.
with regards to your question, my comment are below...
> list1 = ['arr', 'bre', 'grau', 'lower', 'tudo']
> for item in list1:
>if 'arr' in it
#! /usr/bin/python
list1 = ['arr', 'bre', 'grau', 'lower', 'tudo']
for item in list1:
if item == 'arr' or item == 'grau':
print list1
Hopefully, my rewording of one of your tests will make it a bit easier
to see what is happening.
A for statement such as 'for item in list
Hello, I'm trying to teach my self programming with python and there
are some basic things that stumps me:
Given this code:
###
list1 = ['arr', 'bre', 'grau', 'lower', 'tudo']
for item in list1:
if 'arr' in item:
print list1
###
The output is (as expected):
['arr', 'bre', 'grau', 'lower
14 matches
Mail list logo