| | |
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
| Thread Tools | Search this Thread |
abrupt ansi anti approximation assignment avogadro backend beginner binary bluetooth calculator character cmd code customdialog decimals dictionaries dictionary directory drive dynamic error examples excel exe file float format function gnu graphics gui heads homework http ideas import input java launcher leftmouse line linux list lists logging loop module mouse number numbers output parsing path pointer port prime programming progressbar projects push py2exe pygame pyqt python random recursion schedule scrolledtext sqlite statistics stdout string strings sudokusolver sum table terminal text thread threading time tkinter tlapse tricks tuple tutorial twoup ubuntu unicode update urllib urllib2 variable ventrilo wikipedia windows write wxpython xlib





