| | |
Problems with a leet speak converter
Please support our Python advertiser: Programming Forums - DaniWeb Sister Site
![]() |
I tried to make a leet speak converter, but it outputs characters that I don't even tell it to..
This is what I mean:
(Test run)
Enter something to convert to L337 5P34K: Hi, how are you?
L337 5P34K equivilent: hi,@H0w 4R3 Y0u?
I don't know why it's got the '@' there.
This is the code:
This is what I mean:
(Test run)
Enter something to convert to L337 5P34K: Hi, how are you?
L337 5P34K equivilent: hi,@H0w 4R3 Y0u?
I don't know why it's got the '@' there.
This is the code:
python Syntax (Toggle Plain Text)
#L33TSP34K Converter. import random as rnd def toUpper(string): string_upper = "" for char in string : if ord(char) < 97 : string_upper += char elif ord(char) >= 97 : string_upper += chr(ord(char) - 32) return string_upper def toLower(string): string_lower = "" for char in string : if ord(char) > 97 : string_lower += char elif ord(char) <= 97: string_lower += chr(ord(char) + 32 ) return string_lower def convertToLeetSpeak(src): string = src for c in src: if c == 'e' or c == 'E': string += '3' elif c == 'a' or c == 'A': string += '4' elif c == 't' or c == 'T': string += '7' elif c == 's' or c == 'S': string += '5' elif c == 'o' or c == 'O': string += '0' else: i = rnd.randrange(1,3) if i == 1: string += toUpper(c) elif i == 2: string += toLower(c) return string def main(): choice = raw_input("Enter something to convert to L337 5P34K: ") choice = convertToLeetSpeak(choice).replace(choice, '') print 'L337 5P34K equivilent:',choice if __name__ == '__main__': main()
...
•
•
Join Date: Aug 2009
Posts: 56
Reputation:
Solved Threads: 6
0
#2 Oct 30th, 2009
I think it is because you have to be leet to run that code
. J/K...
If you run that then look at line 10 of your script you will see where it came from.
. J/K... python Syntax (Toggle Plain Text)
while count < 256: print(chr(count), count) count += 1
![]() |
Other Threads in the Python Forum
- Previous Thread: How to integrate vumeter
- Next Thread: Converting Python VERSION 3 scripts to .exe
Views: 206 | Replies: 1
| Thread Tools | Search this Thread |
Tag cloud for Python
advanced assignment beginner bluetooth chmod cmd code convert count csv data decimals dictionary dynamic dynamically enter examples excel external file float format frange ftp function gnu gui heads hints homework import input jaunty java leftmouse line linux list lists loan loop module mouse multiple newb number numbers output parsing path pointer port prime program programming projects push py2exe pygame pyglet pyopengl pyqt python random raw_input recursion recursive scrolledtext slicenotation software ssh stderr string strings table tennis terminal text thread threading time tkinter tlapse tooltip tuple tutorial ubuntu unicode unix urllib urllib2 variable variables ventrilo web webservice windows wx.wizard wxpython xlib





