User Profile

Collapse

Profile Sidebar

Collapse
ss30
ss30
Last Activity: Aug 26 '08, 08:02 AM
Joined: Aug 12 '08
Location:
  •  
  • Time
  • Show
  • Source
Clear All
new posts

  • ss30
    started a topic generate list of strings

    generate list of strings

    Hi,

    I'm trying to generate a list of random digits with no repeats. So far i have:

    a = random.sample(r ange(0, 1), n)

    which generates a list of random digits in a list with no repeat such as [1, 3, 5, 9] where n is 4.

    However, i need it to produce a list of string of digits with no repeats, such as ['1', '3', '5', '9']. Is there any simple way to do this?

    Thankyou for r...
    See more | Go to post

  • ss30
    replied to split 1234 into ('1', '2', '3', '4')
    that's brilliant! and so simple!

    Thanks heaps :)...
    See more | Go to post

    Leave a comment:


  • ss30
    started a topic split 1234 into ('1', '2', '3', '4')

    split 1234 into ('1', '2', '3', '4')

    Hi,

    I was wondering if there is a simple way to split 1234 into a string of ('1', '2', '3', '4').

    Also, is there a way to test whether an element of a string (or list) is an integer. For instance, if i had a list a = ['1', '2', '3', '4'], the elements are all integers, the function needs to return True.

    However, if the list was ['1', '2', '3', 'x'], how would i distinguish that 'x' is not an integer and...
    See more | Go to post

  • ss30
    replied to Generate Random List of Integers
    Yes, thankyou :) That helped a lot. I ended up using a while loop, but it seems to work well.

    Thanks!...
    See more | Go to post

    Leave a comment:


  • ss30
    replied to Generate Random List of Integers
    so far i have used

    random.sample(r ange(0, 10), n) where n is the number of digits long.

    This works really well for getting a random list with no repeats, but i need to have a random list where repeats are allowed.
    See more | Go to post

    Leave a comment:


  • ss30
    started a topic Generate Random List of Integers

    Generate Random List of Integers

    Hi,

    I'm really new to python or really any programming at all. I'm trying to write a game and I'm really stuck on one small, seemingly easy task.

    I have to generate a random list of n single digit integers (0 to 9).

    For example, ['1', '5', '2', '8'] where n is 4.

    Please help! I'm going out of my mind!

    Thanks heaps
    See more | Go to post
No activity results to display
Show More
Working...