FAQ
Hi all,
I would like to put an alphanumeric string like this one
EE472A86441AF2E629DE360 in a list, then iterate inside the entire
string lenght and change each digit with a random digit.
Do u have some suggestion? thanks a lot

Search Discussions

  • Chris Rebert at Mar 15, 2011 at 8:20 am

    On Tue, Mar 15, 2011 at 1:10 AM, yqyq22 wrote:
    Hi all,
    I would like to put an alphanumeric string like this one
    EE472A86441AF2E629DE360 in a list, then iterate inside the entire
    string lenght and change each digit with a random digit.
    Do u have some suggestion? thanks a lot
    Can you show us your attempt?

    Cheers,
    Chris
  • Ulrich Eckhardt at Mar 15, 2011 at 8:44 am

    yqyq22 wrote:
    I would like to put an alphanumeric string like this one
    EE472A86441AF2E629DE360 in a list, then iterate inside the entire
    string lenght and change each digit with a random digit.
    What does "change each digit with a random digit"? Do you want to swap two
    random elements of the sequence with each other? The "random" module
    contains a tool to generate random permutations, all you would have to do
    is to split the string into a list, call that function and later join the
    results.

    Uli

    --
    Domino Laser GmbH
    Gesch?ftsf?hrer: Thorsten F?cking, Amtsgericht Hamburg HR B62 932
  • Yqyq22 at Mar 15, 2011 at 8:49 am

    On Mar 15, 9:20?am, Chris Rebert wrote:
    On Tue, Mar 15, 2011 at 1:10 AM, yqyq22 wrote:
    Hi all,
    I would like to put an alphanumeric string like this one
    EE472A86441AF2E629DE360 in a list, then iterate inside the entire
    string lenght and change each digit with a random digit.
    Do u have some suggestion? thanks a lot
    Can you show us your attempt?

    Cheers,
    Chris
    Hi, to be honest i'm a newbye so i don't know where to start, i began
    in this way but i don't know how to proceeed.
    list = (EE472A86441AF2E629DE360)
    Thanks
  • Ben Finney at Mar 15, 2011 at 9:22 am

    yqyq22 <yqyq22 at hotmail.com> writes:
    On Mar 15, 9:20?am, Chris Rebert wrote:
    Can you show us your attempt?
    Hi, to be honest i'm a newbye so i don't know where to start
    Work through the entire Python tutorial, in sequence
    <URL:http://docs.python.org/tutorial/>. Not merely read: work through
    it, reading the explanations, performing the examples, and experimenting
    with them until satisfied you understand, before moving on to the next.

    --
    \ ?I was gratified to be able to answer promptly and I did. I |
    `\ said I didn't know.? ?Mark Twain, _Life on the Mississippi_ |
    _o__) |
    Ben Finney
  • Ulrich Eckhardt at Mar 15, 2011 at 9:51 am

    yqyq22 wrote:
    Hi, to be honest i'm a newbye so i don't know where to start, i began
    in this way but i don't know how to proceeed.
    list = (EE472A86441AF2E629DE360)
    "list" is a builtin type, so you shouldn't use it as name for other things.
    The thing on the right-hand side of the assignment is just the identifier
    EE47... after stripping the brackets, which don't have a meaning there.

    I'd suggest that you start reading a Python tutorial to get some basics down
    first. Start reading at http://docs.python.org.

    Uli

    --
    Domino Laser GmbH
    Gesch?ftsf?hrer: Thorsten F?cking, Amtsgericht Hamburg HR B62 932
  • Laurent Claessens at Mar 15, 2011 at 10:02 am

    Le 15/03/2011 09:10, yqyq22 a ?crit :
    Hi all,
    I would like to put an alphanumeric string like this one
    EE472A86441AF2E629DE360 in a list, then iterate inside the entire
    string lenght and change each digit with a random digit.
    Do u have some suggestion? thanks a lot
    This can be a way to begin :

    s="EE472A86441AF2E629DE360"
    for a in s:
    print a

    The following is a very basic trick to build a list <t> containing the
    elements of the string <s>

    s="EE472A86441AF2E629DE360"
    t=[]
    for a in s:
    t.append(a)

    All that you have to change is t.append(a) into something that
    tests if a is a number and append something else in that case.

    Depending what you want, you can even do

    s.replace("1","ONE").replace("2","TWO").replace("3","FIVE")

    This is however far from being random ;)

    Have good tests
    Laurent
  • Yqyq22 at Mar 15, 2011 at 1:15 pm

    On Mar 15, 11:02?am, Laurent Claessens wrote:
    Le 15/03/2011 09:10, yqyq22 a crit :
    Hi all,
    I would like to put an alphanumeric string like this one
    EE472A86441AF2E629DE360 in a list, then iterate inside the entire
    string lenght and change each digit with a random digit.
    Do u have some suggestion? thanks a lot
    This can be a way to begin :

    s="EE472A86441AF2E629DE360"
    for a in s:
    ? ? print a

    The following is a very basic trick to build a list <t> containing the
    elements of the string <s>

    s="EE472A86441AF2E629DE360"
    t=[]
    for a in s:
    ? ? t.append(a)

    All that you have to change is t.append(a) into something that
    tests if a is a number and append something else in that case.

    Depending what you want, you can even do

    s.replace("1","ONE").replace("2","TWO").replace("3","FIVE")

    This is however far from being random ;)

    Have good tests
    Laurent
    Laurent thanks a lot very much!!! really appreciated it.. now i have a
    good start point thanks again
  • Yqyq22 at Mar 16, 2011 at 9:59 am

    On Mar 15, 2:15?pm, yqyq22 wrote:
    On Mar 15, 11:02?am, Laurent Claessens wrote:




    Le 15/03/2011 09:10, yqyq22 a crit :
    Hi all,
    I would like to put an alphanumeric string like this one
    EE472A86441AF2E629DE360 in a list, then iterate inside the entire
    string lenght and change each digit with a random digit.
    Do u have some suggestion? thanks a lot
    This can be a way to begin :
    s="EE472A86441AF2E629DE360"
    for a in s:
    ? ? print a
    The following is a very basic trick to build a list <t> containing the
    elements of the string <s>
    s="EE472A86441AF2E629DE360"
    t=[]
    for a in s:
    ? ? t.append(a)
    All that you have to change is t.append(a) into something that
    tests if a is a number and append something else in that case.
    Depending what you want, you can even do
    s.replace("1","ONE").replace("2","TWO").replace("3","FIVE")
    This is however far from being random ;)
    Have good tests
    Laurent
    Laurent thanks a lot very much!!! really appreciated it.. now i have a
    good start point thanks again- Hide quoted text -

    - Show quoted text -
    Something like that but it append A to each element of the string

    string = "EE472B"
    t = []
    for x in string[:]:
    print t.append("A") #i don't want to append A, the final
    result is EAEA4A7A2ABA
    # i would like to substitute each element with a random
    string

    How i can use the random module in this case? Thanks
  • Laurent Claessens at Mar 16, 2011 at 1:12 pm

    string = "EE472B"
    t = []
    for x in string[:]:
    print t.append("A") #i don't want to append A, the final
    result is EAEA4A7A2ABA
    As it, it prints "None" 6 times. Then t is ['A','A','A','A','A']

    What you have to do is to read about basic python. Search for python
    tutorial on the net.

    Then try the following exercices :

    Exercises

    1
    print the first 1000 intergers

    2
    print the sine of 1 ... 1000

    3
    print the intergers x between 1 and 1000 such that cos(x) is between 0
    and 0.5


    Have a good afternoon
    Laurent
  • Laurent Claessens at Mar 16, 2011 at 1:13 pm

    string = "EE472B"
    t = []
    for x in string[:]:
    print t.append("A") #i don't want to append A, the final
    result is EAEA4A7A2ABA
    As it, it prints "None" 6 times. Then t is ['A','A','A','A','A']

    What you have to do is to read about basic python. Search for python
    tutorial on the net.

    Then try the following exercices :

    Exercises

    1
    print the first 1000 intergers

    2
    print the sine of 1 ... 1000

    3
    print the intergers x between 1 and 1000 such that cos(x) is between 0
    and 0.5


    Have a good afternoon
    Laurent

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
grouppython-list @
categoriespython
postedMar 15, '11 at 8:10a
activeMar 16, '11 at 1:13p
posts11
users5
websitepython.org

People

Translate

site design / logo © 2022 Grokbase