Letter Shift Problem

For students who are taking a programming course, may be restricted in what they can use, or have other unusual limitations on solving their task.

Letter Shift Problem

Postby nzieno » Sat Sep 17, 2016 1:46 pm

having some trouble with this problem. Write a program that asks for 5 characters, and an integer value (called the key), to produce a new set of 5-characters offset by the number of places in the key. Save your program as shifter.py
Here is an example of the execution:


5-Letter Character Shifter Program
Enter the first letter : U
Enter the second letter: T
Enter the third letter : I
Enter the fourthetter: C
Enter the fifth letter : A
Enter the key value: 5



The offset letters are: ZYNHF

So far I can get the the letters to display but I can't the formula down to shift the letters I know I need to use the ord(ch) and chr functions but I can't the formula down. So far this is what i have down.

Code: Select all
# This program will shift the letters by 5 characters

Letter1 = input("Enter the first letter:",)
Letter2 = input("Enter the second letter:",)
Letter3 = input("Enter the third letter:",)
Letter4 = input("Enter the fourth letter:",)
Letter5 = input("Enter the fifth letter:",)
IntegerValue = int(input("Enter the key value:",))

LetterShift = (Letter1 + Letter2 + Letter3 + Letter4 + Letter5)

LetterShift = chr(ord(ch) + IntegerValue)





print("The offset letters are :",LetterShift)



Any pointers would be greatly appreciated.
nzieno
 
Posts: 16
Joined: Fri Jul 29, 2016 12:38 am

Re: Letter Shift Problem

Postby Yoriz » Sat Sep 17, 2016 2:38 pm

Code: Select all
letter1 = 'U'
shift_value= 5

shift_letter1 = chr(ord(letter1) + shift_value)
print(shift_letter1)

Output
Code: Select all
Z
Due to the reasons discussed here we will be moving to python-forum.io/ on October 1 2016
This forum will be locked down and no one will be able to post/edit/create threads, etc. here from thereafter. Please create an account at the new site to continue discussion.
User avatar
Yoriz
 
Posts: 1672
Joined: Fri Feb 08, 2013 1:35 am
Location: UK

Re: Letter Shift Problem

Postby nzieno » Sat Sep 17, 2016 7:30 pm

Thats not what the program asking for. Your just putting a value in and not allowing the program to enter its own value
nzieno
 
Posts: 16
Joined: Fri Jul 29, 2016 12:38 am

Re: Letter Shift Problem

Postby Yoriz » Sat Sep 17, 2016 7:49 pm

My aim is not to do your homework for you but to give you a hint that you can adapt into your own code.
Due to the reasons discussed here we will be moving to python-forum.io/ on October 1 2016
This forum will be locked down and no one will be able to post/edit/create threads, etc. here from thereafter. Please create an account at the new site to continue discussion.
User avatar
Yoriz
 
Posts: 1672
Joined: Fri Feb 08, 2013 1:35 am
Location: UK


Return to Homework

Who is online

Users browsing this forum: No registered users and 6 guests

cron