Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #98910

Re: palindrome

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:25:47 +0530
Lines 64
Message-ID <mailman.377.1447736189.16136.python-list@python.org> (permalink)
References <s4bl4bd739gfq92c5hipb16grv8a5fh5pb@4ax.com> <mailman.376.1447735216.16136.python-list@python.org> <78cl4bljie79vqr80d1g084jm8ma3k0r9k@4ax.com>
Mime-Version 1.0
Content-Type text/plain; charset=UTF-8
Content-Transfer-Encoding quoted-printable
X-Trace news.uni-berlin.de FMmYUk3weJHu4YBCkvlckAC70JcSwm9VUjLRfu8by9gg==
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.005
X-Spam-Evidence '*H*': 0.99; '*S*': 0.00; 'else:': 0.03; 'received:209.85.223': 0.03; 'cc:addr:python-list': 0.09; '"not"': 0.16; '>on': 0.16; 'better?': 0.16; 'input.': 0.16; 'received:io': 0.16; 'received:psf.io': 0.16; 'true:': 0.16; '\xc2\xa0if': 0.16; 'wrote:': 0.16; 'string': 0.17; 'typing': 0.18; '&gt;': 0.18; 'email addr:gmail.com&gt;': 0.18; 'input': 0.18; '2015': 0.20; 'cc:2**0': 0.20; 'cc:addr:python.org': 0.20; '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; 'cool': 0.27; 'asks': 0.29; 'random': 0.29; 'print': 0.30; 'getting': 0.33; 'picking': 0.33; 'tue,': 0.34; 'skip:& 20': 0.35; 'received:google.com': 0.35; 'nov': 0.35; 'skip:> 10': 0.35; 'should': 0.36; 'instead': 0.36; 'url:org': 0.36; 'received:209.85': 0.36; 'subject:: ': 0.37; 'skip:& 10': 0.37; 'missing': 0.37; 'thought': 0.37; 'received:209': 0.38; 'why': 0.39; 'your': 0.60; 'url:2014': 0.66; 'here': 0.66; 'skip:\xc2 10': 0.67; '>if': 0.84; '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=k8Y5S38XfnwhU35l1kmle1rhic8tdmyL2m7F1OKNzpU=; b=0K7FGxh2YStGMKbLrClwHBTV3k4rmEX6yO1+FVJqaQ+ckDW2aZyVOtSvuFc8Nr8qeA 6b1Gv16jrYX4cvnrnddb5aimIP5cw+gycrVxiTP9C1RE1PULjfJhNlawzIJ4n04g/XcR zUxwY6fhojJ8wC49ELF/Id49GK776FIgMo8H1uRPayP8NLcLlJWRvI5EazeUsXa/2ATz EzcKS022/CQCVP3KBSnNtpKdtPTxXOZ1+kESm2IIRJdY2+PLXlAGTh5YY239mKthUcWQ puLEjP/J9u2K2/Ei5G8S0r8Qb5N/s+mM/wVEtN227uz+ccxxPnOQwoGOrKQTdL0IYdsw o2VQ==
X-Received by 10.107.132.211 with SMTP id o80mr34003816ioi.85.1447736187112; Mon, 16 Nov 2015 20:56:27 -0800 (PST)
In-Reply-To <78cl4bljie79vqr80d1g084jm8ma3k0r9k@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:98910

Show key headers only | View raw


On Tue, Nov 17, 2015 at 10:18 AM, Seymore4Head <Seymore4Head@hotmail.invalid
> wrote:

> On Tue, 17 Nov 2015 10:09:27 +0530, Abhiram R
> <abhi.darkness@gmail.com> wrote:
>
> >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??
> >
> The instructions do ask for input.  I am lazy.  I thought it would be
> cool to have random input instead of just typing a phrase.
> --
>
>
​Haha. Nice. Although with your length of string and the range you're
picking from,the chances of you getting a palindrome are (1/24!)  :D ​




-- 
-Abhiram R

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


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