Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    Regular Coder
    Join Date
    Apr 2007
    Location
    U.S.A
    Posts
    129
    Thanks
    1
    Thanked 0 Times in 0 Posts

    noob doesn't know whats wrong

    Hey guys I've started my very first program ever, lol yay.
    Anyways, of course I'm having a problem (never fails).
    I am trying to make a program that takes a word, and ceaser encodes it, or shifts it's alphibet place. Hopefully you will understand from the program. I haven't started on the undoing part, as for some reason the code is not responding. I don't get an error message, and it does not print "test" in the shell.
    Heres the code
    Code:
    print "test"
    letters = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z',1 ,2 , 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]
    word = ("hello")
    len(word) = var_1
    var_2 = 0
    d = []
    encoded= []
    var_4 = 0
    while var_2 < (var_1 + 1):
        letters.index(word[var_2]) = var_3
        var_3 + 5 = x
        d.append(x)
        var_2 = var_2 + 1
    while var_4 < (var_1 + 1):
        mid.append(letters[d[var_4]])
        var_4 = var_4 + 1
    encoded = "".join(mid)
    print encoded
    Please help understand what is wrong, as I'm very new to the language, and I've only had about five nights to study it so far.

    Thanks,

    Joe

  • #2
    New Coder
    Join Date
    May 2006
    Posts
    39
    Thanks
    0
    Thanked 1 Time in 1 Post
    Quote Originally Posted by awsomejoe23 View Post
    Hey guys I've started my very first program ever, lol yay.
    Anyways, of course I'm having a problem (never fails).
    I am trying to make a program that takes a word, and ceaser encodes it, or shifts it's alphibet place. Hopefully you will understand from the program. I haven't started on the undoing part, as for some reason the code is not responding. I don't get an error message, and it does not print "test" in the shell.
    Heres the code
    Code:
    print "test"
    letters = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z',1 ,2 , 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]
    word = ("hello")
    len(word) = var_1
    var_2 = 0
    d = []
    encoded= []
    var_4 = 0
    while var_2 < (var_1 + 1):
        letters.index(word[var_2]) = var_3
        var_3 + 5 = x
        d.append(x)
        var_2 = var_2 + 1
    while var_4 < (var_1 + 1):
        mid.append(letters[d[var_4]])
        var_4 = var_4 + 1
    encoded = "".join(mid)
    print encoded
    Please help understand what is wrong, as I'm very new to the language, and I've only had about five nights to study it so far.

    Thanks,

    Joe
    did you really run your code using the Python interpreter? If you have, you will get errors, i am sure of that. Your LHS and RHS of your assignment is messed up.
    Code:
    len(word) = var_1
    should be
    Code:
    var_1 = len(word)
    similarly for
    Code:
    letters.index(word[var_2]) = var_3
    and
    Code:
    var_3 + 5 = x
    Fix them and then run your code again.

    PS. there are better ways to do what you are doing.

  • #3
    New Coder
    Join Date
    Jun 2006
    Posts
    22
    Thanks
    0
    Thanked 0 Times in 0 Posts
    you are trying to make an ROT 13 cypher! Have you you can bunch your code a little by writing by makes statements like alpha = [A-z] etc..


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •