473,378 Members | 1,622 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,378 software developers and data experts.

Rearranging letters

Hey

This is my first post here and i hope you can help :)
I would like to create a very basic easy program that can rearrange letters.
It would take the inputed word process it and print the new word out

for example if you entered the word job it would move each letter 3 spaces backwards so the printed result would be "gly"

What would be the best way to approach this

Thankyou in advance
Nov 29 '07 #1
3 8171
bvdet
2,851 Expert Mod 2GB
Hey

This is my first post here and i hope you can help :)
I would like to create a very basic easy program that can rearrange letters.
It would take the inputed word process it and print the new word out

for example if you entered the word job it would move each letter 3 spaces backwards so the printed result would be "gly"

What would be the best way to approach this

Thankyou in advance
Make a string of ascii letters:
Expand|Select|Wrap|Line Numbers
  1. >>> import string
  2. >>> string.ascii_lowercase
  3. 'abcdefghijklmnopqrstuvwxyz'
  4. >>> letters = string.ascii_lowercase
The string index of each letter can be found by using the string method index(). Subtract 3 from the index number, and get the new letter from the string using the slice operator.
Expand|Select|Wrap|Line Numbers
  1. >>> word = 'job'
  2. >>> ''.join([letters[letters.index(letter)-3] for letter in word])
  3. 'gly'
  4. >>> 
Nov 29 '07 #2
ghostdog74
511 Expert 256MB
Expand|Select|Wrap|Line Numbers
  1. >>> s="def"
  2. >>> ''.join([chr(ord(ch)-3) for ch in s])
  3. 'abc'
  4.  
Nov 29 '07 #3
That worked great thanks alot :)

I wrote it line by line into the python command line. Is there anyway to copy it out like into a text file and just change the word whenever i want menaing i don't have to repeatly write it out for just one word

thanks in advance

Edit: That was to the first reply. I will look at the second reply now

edit again: They both worked great. Now if i can only work out how to save it i will be sitting good :D
Nov 29 '07 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Edward K. Ream | last post by:
From the documentation for the string module at: C:\Python23\Doc\Python-Docs-2.3.1\lib\module-string.html letters: The concatenation of the strings lowercase and uppercase described below....
19
by: Johannes Nix | last post by:
Hello, yesterday I met a cute person (after my dance class) who told me about an interesting experiment regarding cognition. People were told to read a typed text; However, in every word in the...
1
by: Tor Inge Rislaa | last post by:
Rearranging the row position in a datagrid Hi I have a datagrid that I fill from a dataset. When the data is displayed in the grid I want the user to be able to move the position of a row. E.g....
7
by: stevenkobes | last post by:
A lot of websites have forms with an image at the bottom containing some distorted / noisy letters and numbers that users must type in to prove they are real people. How do they normally implement...
1
by: Kosmos | last post by:
Since people have been so helpful on this site I thought I'd contribute what little I can...since I am not a programmer but I'm working on an access database for work Anyways I had to remove...
4
by: db2admin | last post by:
Hello, I want to plan rearranging tables in our database according to business areas. say all tables in business area A will be in seperate tablespace or tablespaces. I am planning to monitor...
0
by: selvakumari | last post by:
hi, In my project in a treeview i am doing drag and drop function and after that modifying some values in a treeview ascending order of nodes, some times the treeview may contain 255 nodes each...
8
by: trixxnixon | last post by:
Could Rearranging columns on a table, effect other areas of the database such as reports and queries?
4
by: abueno | last post by:
//It should count how many characters are letters in the English alphabet, and is displaying the correct letters, but is not counting good. void FunctionCountLetters(char s) { int len; int i;...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.