Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #98908
| Path | csiph.com!fu-berlin.de!uni-berlin.de!not-for-mail |
|---|---|
| From | Abhiram R <abhi.darkness@gmail.com> |
| Newsgroups | comp.lang.python |
| Subject | Re: palindrome |
| Date | Tue, 17 Nov 2015 10:09:27 +0530 |
| Lines | 45 |
| Message-ID | <mailman.376.1447735216.16136.python-list@python.org> (permalink) |
| References | <s4bl4bd739gfq92c5hipb16grv8a5fh5pb@4ax.com> |
| Mime-Version | 1.0 |
| Content-Type | text/plain; charset=UTF-8 |
| Content-Transfer-Encoding | quoted-printable |
| X-Trace | news.uni-berlin.de aini+HFj3CZ02SDX7ykezgfvGdwONX/TNv21T+BsJrdA== |
| Return-Path | <abhi.darkness@gmail.com> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.017 |
| X-Spam-Evidence | '*H*': 0.97; '*S*': 0.00; 'else:': 0.03; 'cc:addr :python-list': 0.09; '"not"': 0.16; 'better?': 0.16; 'received:io': 0.16; 'received:psf.io': 0.16; 'true:': 0.16; 'wrote:': 0.16; 'input': 0.18; '2015': 0.20; 'cc:2**0': 0.20; 'cc:addr:python.org': 0.20; 'trying': 0.22; 'am,': 0.23; 'import': 0.24; 'header:In-Reply-To:1': 0.24; 'not.': 0.27; 'question': 0.27; 'message-id:@mail.gmail.com': 0.27; 'asks': 0.29; 'random': 0.29; 'print': 0.30; 'right?': 0.33; 'tue,': 0.34; 'skip:& 20': 0.35; 'received:google.com': 0.35; 'nov': 0.35; 'should': 0.36; 'url:org': 0.36; 'received:209.85': 0.36; 'subject:: ': 0.37; 'skip:& 10': 0.37; 'thanks': 0.37; 'missing': 0.37; 'received:209.85.213': 0.37; 'received:209': 0.38; 'why': 0.39; 'url:2014': 0.66; 'here': 0.66; 'seymore4head': 0.84; 'url:03': 0.84 |
| DKIM-Signature | v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc:content-type; bh=sJShctso3QVCuuT1vyfmcEMUt3d43ZAehMfSFbh+wzk=; b=XdeEanSwNhRmnMTv99F4n0AZwg2hy2XsztGq5p2df1u7riROk8gUkvHISA5ONbdmcB yFnMiM5L7KHNLxXZ6//m2WtEZSAtpbMUAQ5F2s1V6EHMi+CWXVwDsCYaRSYvMJxBw1ob uuPgNgL8KpPGhsgVWosFK5tQoGRZ4l/1eUMUykXPMYXFa2WuaMBL31JMN7iHuhGf0QdG DBjlD9otFaFIxM2kQ3JcJzySrfOM1uUGJ1XNmC5wHQFRcznduoSG2RodblrtOr3mwThM Fn5w+VBM4gaTx+BvQ+MttBabNh9S6q4n6w9xz6ggbqQkVsPxWhOh9gnc6GXXHy/zfnm3 /VQg== |
| X-Received | by 10.50.59.179 with SMTP id a19mr11274igr.59.1447735207388; Mon, 16 Nov 2015 20:40:07 -0800 (PST) |
| In-Reply-To | <s4bl4bd739gfq92c5hipb16grv8a5fh5pb@4ax.com> |
| X-Content-Filtered-By | Mailman/MimeDel 2.1.20+ |
| X-BeenThere | python-list@python.org |
| X-Mailman-Version | 2.1.20+ |
| 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> |
| Xref | csiph.com comp.lang.python:98908 |
Show key headers only | View raw
On Tue, Nov 17, 2015 at 9:59 AM, Seymore4Head <Seymore4Head@hotmail.invalid>
wrote:
> http://www.practicepython.org/exercise/2014/03/12/06-string-lists.html
>
> Here is my answers. What would make it better?
>
> import random
> str1=""
> letcount=4
> count=0
> abc='abcdefghijklmnopqrstuvwxyz'
> while True:
> for i in range(letcount):
> a=random.choice(abc)
> str1+=a
> print str1
> count+=1
> if str1==str1[::-1]:
> break
> else:
> str1=""
> print "Tries= ",count
> print str1
> --
>
>
The question asks to get an input from the user and print if it's a
palindrome or not.
It should be just
strA=raw_input()
if strA==strA[::-1]:
print "Palindrome"
else:
print "Not"
Right? Am I missing something? Why are you generating random strings and
trying to check for palindromes?
Thanks
Abhiram R (IRC - abhiii5459_ ; Twitter - https://twitter.com/abhiii5459)
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
palindrome Seymore4Head <Seymore4Head@Hotmail.invalid> - 2015-11-16 23:29 -0500
Re: palindrome Abhiram R <abhi.darkness@gmail.com> - 2015-11-17 10:09 +0530
Re: palindrome Seymore4Head <Seymore4Head@Hotmail.invalid> - 2015-11-16 23:48 -0500
Re: palindrome Abhiram R <abhi.darkness@gmail.com> - 2015-11-17 10:25 +0530
Re: palindrome Peter Otten <__peter__@web.de> - 2015-11-17 10:48 +0100
Re: palindrome Peter Otten <__peter__@web.de> - 2015-11-17 10:31 +0100
csiph-web