Two newbie questions
richard_chamberlain
richard_chamberlain at ntlworld.com
Tue Jun 13 12:37:41 EDT 2000
More information about the Python-list mailing list
Tue Jun 13 12:37:41 EDT 2000
- Previous message (by thread): Two newbie questions
- Next message (by thread): Two newbie questions
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
doh, >>random.randint(0,i-1) where i is maxint Richard richard_chamberlain <richard_chamberlain at ntlworld.com> wrote in message news:Mgt15.508$9K.10789 at news6-win.server.ntlworld.com... > or, > > import string > st=string.join(l,'') > > will do it. > > if you do your random thing interactively and don't assign to i you'll > notice you get an exception so you'll have to play around based on that. > > I'm sure I'll be corrected but I guess the range your trying to use > (-maxint-1 to maxint) is not an int it's a long so it doesn't work. > > random.randint(0,i-1) > > does work though. > > > Richard > > Arkaitz <ma9aba at bath.ac.uk> wrote in message > news:20000613165659.A7828 at basajaun... > > Hi all, > > > > I'm learning Python, as it seems everybody around here :-), and I found > two > > problems that I can't find the solution to: > > 1. As the strings are inmutable, if I want to modify the order of the > characters > > in the string(e.g. sort them), what I do is: > > > > st = "asdfasfasdf" > > l = [] > > for c in st: > > l.append(c) > > > > Then I process the list, and the problem is that I have no idea of how I > can get > > the string back, any help? > > 2. The second question is about random numbers, how can I get a random int > between the minimum and maximum integers of the machine? > > The next code doesn't worK > > import sys, random > > > > i = random.randint(-sys.maxint-1, sys.maxint) > > > > Thanks in advance, > > > > Arkaitz. > > > >
- Previous message (by thread): Two newbie questions
- Next message (by thread): Two newbie questions
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-list mailing list