## New to Python; Trying a Hash

For the discussion of Perl, Python, Ruby, and PHP and other interpreted languages.

### New to Python; Trying a Hash

Hello... first post on this great site! I was curious as to how to go about creating a simple little program to has individual or strings of characters. I'm sure there are numerous ways to do this, but I want something simple to start with, then I can add and modify ways later on as I explore.. Any idea's or links to such feats?

LostinCyberia
New User

Posts: 13
Joined: Wed Jul 25, 2012 9:42 am
Blog: View Blog (0)

### Re: New to Python; Trying a Hash

A good start would be to look at more basic algorithms that you can visualize working in a program. Probably the caesar cipher would be a good start.

-- Fri Jul 27, 2012 7:13 am --

And because I like Python, I wrote a quick example for you

Code: Select all
# here you go

shift = 2

ans = raw_input("enter letter " )

#print ans[]

new =  ord(ans) + shift
print chr(new)

It works on one letter, perhaps you could change it and make it better

wan26
Experienced User

Posts: 91
Joined: Sun Jan 22, 2012 6:46 pm
Blog: View Blog (0)

### Re: New to Python; Trying a Hash

Thanks for your reply! I came up with this one. It's just a numerical cipher

# A Simple Casser Cipher

shift = 4

outcome = input ("Enter Value Here ")

print "The Ciphered text is: "
print outcome + shift

LostinCyberia
New User

Posts: 13
Joined: Wed Jul 25, 2012 9:42 am
Blog: View Blog (0)

### Re: New to Python; Trying a Hash

I like what you did with the numbers but maybe something that starts to get more practical would work too, I changed my original slightly:

Code: Select all
text = 'abcdefhijklmopqrstuvwxyz'
new = [''] * len(text)
shift = 4

for i in range (0, len(text)):
new[i] = chr(ord(text[i]) + shift)

print new

Trying this in c++ is interesting too,

wan26
Experienced User

Posts: 91
Joined: Sun Jan 22, 2012 6:46 pm
Blog: View Blog (0)

### Who is online

Users browsing this forum: No registered users and 0 guests