Jump to content

Snakes


anyedie

Recommended Posts

calling all coders!

Help a poor python noob.

ive spent 2 days (not stright, thad be crazy!) searing and for the life of me cannot find how to modify user input. its driving me crazy. i think ive worked with nearly everything in the string library and cannot get it right. can someone help with this?

ahhh! string.replace.... why cant i harness your power!!!!

*gulp..*

did i say something wrong? 18 views 0 responses :(

Link to comment
Share on other sites

yes bliz you can... ( what im working on is top secret, but will be posted here later)

for example, lets say i want to make a L337 h4x0r sp3ak translator.

user enters

hi im jenny, how are you today?

i would want to replace certain characters in there input.

i would want to modify there input and print

)-( i 1// j3//nY, )-(0// ar3 Y0u t0daY?

Link to comment
Share on other sites

btw, to answer your python question, I googled and basically found that:

import re



p = re.compile('Hello')

p.sub('Good Bye', 'Hello, World!')

// produces: Good Bye, World!

I hope I could help you.

Link to comment
Share on other sites

btw, to answer your python question, I googled and basically found that:

import re



p = re.compile('Hello')

p.sub('Good Bye', 'Hello, World!')

// produces: Good Bye, World!

I hope I could help you.

thankx blizz, yea, i found that, but i cannot get it to work correctly. + after playing with that i have no idea what its doing. plus with the user input all my planning just goes down the shute.

Link to comment
Share on other sites

my code thus far.

from Tkinter import *

# from re import *        ?

# from string import *    ?



def insert():

    name = ent.get()                   #i know that somewhere you can 

    print name                         # replace the entered text 'ent'

    listbox.insert(END,name)           # but am having an impossible time

    ent.delete(0,END)                  # trying to get this done!

    

root = Tk()

root.geometry('200x210+350+70')



ent = Entry(root)

button = Button(root, text = 'Leet Me Up!', command = insert)

listbox = Listbox(root)



ent.pack()

button.pack()

listbox.pack()



root.mainloop()

Link to comment
Share on other sites

http://docs.python.org/lib/string-methods.html

take a look at the documentation for replace.

it takes two parameters anda third optional parameter.

The first parameter is the string you want replaced. the second is the string to replace it with, and the optional is the number of times to do it

so say you want to replace e with 3. you would do

name = ent.get()

name = name.replace("e", "3")

that will replace all occurences of "e" in name with "3"

Link to comment
Share on other sites

http://docs.python.org/lib/string-methods.html

take a look at the documentation for replace.

it takes two parameters anda third optional parameter.

The first parameter is the string you want replaced. the second is the string to replace it with, and the optional is the number of times to do it

so say you want to replace e with 3. you would do

name = ent.get()

name = name.replace("e", "3")

that will replace all occurences of "e" in name with "3"

THANKX!!! Arrrrrg! coding sux for me because i do dumb things like this and never see it! i had it correct probably 5 times EXCEPT i was putting

ent.replace

insted of name.replace.

Thankx sharpen!

Link to comment
Share on other sites

ok last thing... mml, im likeing l33t sp34ker.

i was thinking... and it would be kinda lame if everything was the same replacement... like above when i wrote sp34er.. that is much better than sp34k3r, i think. Or what if i wanted to replace some of the E's with 3 and some with < or something else.

the question is, does anyone know how i could get the program to replace some instances of 'o' with 0 and some with '()'. I think that the best way would be to use the random module, and make variables for each letter that could have more than one output in leet. then have it replace like sharpen pointed out.

the problem with that is it returns the same random out put for every instance. the o's are always (n)0000000000000000000(b) insted of

0()()00()0()

im stumped.

Link to comment
Share on other sites

Be sure when you are randomly replacing things that you set the number of occurences to replace as 1 or whatever. You may want to iterate through the string (I don't program in python so I don't know how easy it is) and copy each character into a temp string. Randomly l33t it, then append it to an output string. Also be sure to set the random number generator's seed to the clock (if that is necessary in python).

Link to comment
Share on other sites

If you make a leet speak maker, I'll personally fly over to America and kick your ass.

mml! (makes me laugh)

first of all, Leet Speaker is an example as to not give away something. BUT: seeing as how you are so intrested in it, i will be releasing it in the coding section very soon, per your request.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...