Path: csiph.com!usenet.pasdenom.info!weretis.net!feeder1.news.weretis.net!feeder.erje.net!newsfeed.xs4all.nl!newsfeed5.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.020 X-Spam-Evidence: '*H*': 0.96; '*S*': 0.00; 'subject:number': 0.09; 'random': 0.13; 'print': 0.15; 'cc:addr:python-list': 0.15; 'subject:random': 0.16; 'def': 0.20; 'header:In-Reply-To:1': 0.22; 'header:User-Agent:1': 0.23; '>>>': 0.24; 'this?': 0.24; 'cc:no real name:2**0': 0.26; 'cc:addr:python.org': 0.27; 'cc:2**0': 0.31; 'skip:( 30': 0.34; 'charset:us-ascii': 0.36; 'how': 0.40; 'content-disposition:inline': 0.62 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=univie.ac.at; s=rev2; h=In-Reply-To:Content-Type:MIME-Version:References:Message-ID:Subject:Cc:To:From:Date; bh=I9C2JaP2uu30A+p2KedEKl5jyEc1lMIBtkwLJ74h5ZQ=; b=mO1ujZgcGV2L1iY6YiV8+Ipf0hQ9NMN2JjXKtVHxZ6mC37zO0ekDiogMI7TPpRYvSHjU4gJ8spYvipheDwIXF9ap6BhBC/v3lYUcIezTHjn5ZnalQ77Ach0XusuN+762hMqSBEYgYLnuoL6M+kzcTw9XfnBGTr9j1i7Kfo1Cft8=; Date: Mon, 26 Mar 2012 08:40:00 +0200 From: Michael Poeltl To: Nikhil Verma Subject: Re: random number References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.21 (2010-09-15) X-Univie-Virus-Scan: scanned by ClamAV on jarvis.univie.ac.at Cc: python-list@python.org X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 14 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1332744526 news.xs4all.nl 6914 [2001:888:2000:d::a6]:33191 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:22159 * Nikhil Verma [2012-03-26 08:09]: > Hi All > > How can we generate a 6 digit random number from a given number ? what about this? >>> given_number=123456 >>> def rand_given_number(x): ... s = list(str(x)) ... random.shuffle(s) ... return int(''.join(s)) ... >>> print (rand_given_number(given_number)) 653421