Python Forum
Change each character of list into an different characters
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Change each character of list into an different characters
#2
Got Results:

Output:
import ast mylist=ast.literal_eval(input()) stringMessage=mylist[0] shift_value=mylist[1] #start writing your code from here def shift_string(message, n): list1=[] for i in message: ch = i base = ord('a' if ch.islower() else 'A') x = chr((ord(ch) - base - n) % 26 + base) list1.append(x) return("".join(list1)) print(shift_string(stringMessage,shift_value))
Reply


Messages In This Thread
RE: Change each character of list into an different characters - by Angry_bird89 - Jun-19-2020, 08:29 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Replacing a few characters of a specified character but not all of them from a string fatherted99 7 3,453 Aug-13-2020, 09:08 AM
Last Post: fatherted99
  Unexpected change to a list in a small amount of self-contained code Johno 5 2,990 Mar-15-2020, 05:06 PM
Last Post: jefsummers
  Search character from 2d list to 2d list AHK2019 3 2,590 Sep-25-2019, 08:14 PM
Last Post: ichabod801
  Print strings enclosed with a character with different characters aylmaoxd 1 1,995 Aug-17-2019, 03:35 PM
Last Post: Resistance
  Remove special character from list vestkok 3 4,377 Nov-04-2018, 01:48 PM
Last Post: ichabod801
  Unexpected character after line continuation character joshyb123 5 10,823 Sep-05-2018, 08:08 AM
Last Post: perfringo
  unexpected character after line continuation character error newbie 10 14,957 Aug-09-2018, 06:07 PM
Last Post: nilamo
  Sorting list of names by first two characters Otbredbaron 2 3,356 May-24-2018, 03:59 PM
Last Post: Otbredbaron

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020