Path: csiph.com!fu-berlin.de!uni-berlin.de!not-for-mail From: Abhiram R Newsgroups: comp.lang.python Subject: Re: palindrome Date: Tue, 17 Nov 2015 10:25:47 +0530 Lines: 64 Message-ID: References: <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: 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; '>': 0.18; 'email addr:gmail.com>': 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 List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Xref: csiph.com comp.lang.python:98910 On Tue, Nov 17, 2015 at 10:18 AM, Seymore4Head wrote: > On Tue, 17 Nov 2015 10:09:27 +0530, Abhiram R > wrote: > > >On Tue, Nov 17, 2015 at 9:59 AM, Seymore4Head > > >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=3D"" > >> letcount=3D4 > >> count=3D0 > >> abc=3D'abcdefghijklmnopqrstuvwxyz' > >> while True: > >> for i in range(letcount): > >> a=3Drandom.choice(abc) > >> str1+=3Da > >> print str1 > >> count+=3D1 > >> if str1=3D=3Dstr1[::-1]: > >> break > >> else: > >> str1=3D"" > >> print "Tries=3D ",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=3Draw_input() > >if strA=3D=3DstrA[::-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. > -- > > =E2=80=8BHaha. 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 =E2=80= =8B --=20 -Abhiram R