Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #111752
| Path | csiph.com!fu-berlin.de!uni-berlin.de!not-for-mail |
|---|---|
| From | Random832 <random832@fastmail.com> |
| Newsgroups | comp.lang.python |
| Subject | Re: Just starting to learn Python, and encounter a problem |
| Date | Fri, 22 Jul 2016 10:30:05 -0400 |
| Lines | 31 |
| Message-ID | <mailman.49.1469197808.22221.python-list@python.org> (permalink) |
| References | <ac35006b-ab2e-44f1-b896-cd57d9689c73@googlegroups.com> <1469197805.1500560.673872225.0F14EA3D@webmail.messagingengine.com> |
| Mime-Version | 1.0 |
| Content-Type | text/plain |
| Content-Transfer-Encoding | 7bit |
| X-Trace | news.uni-berlin.de ihh827sZvP6/gXYpBeG5sQ1jIC3NTMQGDkUWzYSWDCEg== |
| Return-Path | <random832@fastmail.com> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.002 |
| X-Spam-Evidence | '*H*': 1.00; '*S*': 0.00; 'else:': 0.03; 'subject:Python': 0.05; '22,': 0.09; 'precedence': 0.09; 'received:internal': 0.09; 'yeah,': 0.09; '"michael': 0.16; '"or"': 0.16; '"write': 0.16; '(name': 0.16; 'message- id:@webmail.messagingengine.com': 0.16; 'name",': 0.16; 'non- empty': 0.16; 'received:10.202': 0.16; 'received:10.202.2': 0.16; 'received:66.111': 0.16; 'received:66.111.4': 0.16; 'received:io': 0.16; 'received:messagingengine.com': 0.16; 'received:psf.io': 0.16; 'wrote:': 0.16; '"you': 0.18; 'subject:problem': 0.22; 'header:In-Reply-To:1': 0.24; '(e.g.': 0.27; 'fri,': 0.27; 'asks': 0.29; 'tutorial': 0.29; 'becomes': 0.30; 'true.': 0.33; 'false': 0.35; 'quite': 0.35; 'but': 0.36; 'to:addr:python-list': 0.36; 'subject:: ': 0.37; 'received:10': 0.37; 'say': 0.37; 'received:66': 0.38; 'whatever': 0.39; 'to:addr:python.org': 0.40; 'your': 0.60; 'header:Message-Id:1': 0.61; 'here:': 0.63; 'said:': 0.66; 'jul': 0.72; 'leo': 0.84; 'subject:learn': 0.84; 'subject:Just': 0.91 |
| DKIM-Signature | v=1; a=rsa-sha1; c=relaxed/relaxed; d=fastmail.com; h= content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to:x-sasl-enc :x-sasl-enc; s=mesmtp; bh=/7LODX48hytXNDukRl93eeGSDDE=; b=aYKBgZ 6lAtGrh38GMXQwmGI2+qVbVR9n3K91BRMKdi7C9KAGsZPE8dQuzzG5L77PRMOoJ6 g0ZN0oPY+sTK08CJgtWHOwQbhdKlqgVPdBokrPZJYS3VyljyFsSLjJV7modUF4nQ m3cCG9S68y4/z+lrvQLC/K8UYC2zoQ9KxgaMc= |
| DKIM-Signature | v=1; a=rsa-sha1; c=relaxed/relaxed; d= messagingengine.com; h=content-transfer-encoding:content-type :date:from:in-reply-to:message-id:mime-version:references :subject:to:x-sasl-enc:x-sasl-enc; s=smtpout; bh=/7LODX48hytXNDu kRl93eeGSDDE=; b=ZkO6SZwDAHCY842aix5KL68Hktm3dWog3LC716Jmt6DkTau 2CBhxKfCmp2v6bdw0cLuAVSKXiOQpiKkkHJHi4q5d1xQOj1fC5fgfbCdHqOs1ee4 tgIP6YPEP+rz+Dj+ei9vyESgG9GP0UH+veQlbFmvOql7jqjxAUKJFwRv1mF0= |
| X-Sasl-Enc | Cf4aHTgz3OzbGahzPMqaoLZEE1cics7IcT/XTdHbpSwk 1469197805 |
| X-Mailer | MessagingEngine.com Webmail Interface - ajax-2ccfea0a |
| In-Reply-To | <ac35006b-ab2e-44f1-b896-cd57d9689c73@googlegroups.com> |
| X-BeenThere | python-list@python.org |
| X-Mailman-Version | 2.1.22 |
| Precedence | list |
| List-Id | General discussion list for the Python programming language <python-list.python.org> |
| List-Unsubscribe | <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe> |
| List-Archive | <http://mail.python.org/pipermail/python-list/> |
| List-Post | <mailto:python-list@python.org> |
| List-Help | <mailto:python-list-request@python.org?subject=help> |
| List-Subscribe | <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe> |
| X-Mailman-Original-Message-ID | <1469197805.1500560.673872225.0F14EA3D@webmail.messagingengine.com> |
| X-Mailman-Original-References | <ac35006b-ab2e-44f1-b896-cd57d9689c73@googlegroups.com> |
| Xref | csiph.com comp.lang.python:111752 |
Show key headers only | View raw
On Fri, Jul 22, 2016, at 09:59, Zagyen Leo wrote:
> yeah, it may be quite simple to you experts, but hard to me.
>
> In one of exercises from the Tutorial it said: "Write a program that asks
> the user their name, if they enter your name say "That is a nice name",
> if they enter "John Cleese" or "Michael Palin", tell them how you feel
> about them ;), otherwise tell them "You have a nice name."
>
> And i write so:
>
> name = input("Enter your name here: ")
> if name == "John Cleese" or "Michael Palin":
> print("Sounds like a gentleman.")
> else:
> print("You have a nice name.")
>
> But strangely whatever I type in (e.g. Santa Claus), it always say
> "Sounds like a gentleman.", not the result I want.
"or" is a lower precedence than "==".
> if name == "John Cleese" or "Michael Palin"
becomes if (name == "John Cleese") or "Michael Palin"; becomes if False
or "Michael Palin"; becomes if "Michael Palin"; and non-empty strings
are considered true.
You want if Name == "John Cleese" or Name == "Michael Palin"; or if Name
in ("John Cleese", "Michael Palin")
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Just starting to learn Python, and encounter a problem Zagyen Leo <zagyen@gmail.com> - 2016-07-22 06:59 -0700
Re: Just starting to learn Python, and encounter a problem Random832 <random832@fastmail.com> - 2016-07-22 10:30 -0400
Re: Just starting to learn Python, and encounter a problem Zagyen Leo <zagyen@gmail.com> - 2016-07-22 23:13 -0700
Re: Just starting to learn Python, and encounter a problem Bob Gailer <bgailer@gmail.com> - 2016-07-22 10:36 -0400
Re: Just starting to learn Python, and encounter a problem gst <g.starck@gmail.com> - 2016-07-23 11:18 -0700
Re: Just starting to learn Python, and encounter a problem MRAB <python@mrabarnett.plus.com> - 2016-07-23 20:06 +0100
Re: Just starting to learn Python, and encounter a problem Steven D'Aprano <steve@pearwood.info> - 2016-07-24 11:58 +1000
Re: Just starting to learn Python, and encounter a problem Gordon Levi <gordon@address.invalid> - 2016-07-23 00:37 +1000
Re: Just starting to learn Python, and encounter a problem justin walters <walters.justin01@gmail.com> - 2016-07-22 08:04 -0700
Re: Just starting to learn Python, and encounter a problem MRAB <python@mrabarnett.plus.com> - 2016-07-22 16:08 +0100
csiph-web