Text Scrambler

This program demonstrates an interesting phenomenon regarding reading. It shows, that we are not reading letter by letter, but rather word by word.
Taht is why you can mkae snsee of this sennetce.

A scrambled text


# Python 2.7.7 Code
# Jonathan Frech 6th of September, 2015
#        edited 18th of September, 2015

# import modules
import random, re

# get input
TXT = raw_input("text: ")
STR = ""

for txt in re.split(" +", TXT):
	# process
	if len(txt) > 2:
		letters = []
		for _ in txt[1:len(txt)-1]:
			letters.append(_)
		
		_txt = ""
		for _ in range(0, len(txt)-2):
			r = random.randint(0, len(letters)-1)
			_txt += letters[r]
			letters.pop(r)
		
		STR += txt[0] + _txt + txt[len(txt)-1] + " "
	else:
		STR += txt + " "

# output
print
print STR
print
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s