Python Forum
Help with getting sub-program to print text
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Help with getting sub-program to print text
#1
I'm trying to use the following sub-program to print a shift code:
def shift():
    message = input("Please enter a message:")
    number = int(input('Please enter the number that you would like to shift by (1-26):'))
    new_message = ""
    for letter in message:
        letter = letter.lower()
        if letter.isalpha():
            new_position = alphabet.index(letter) + number
            if new_position > 25:
                new_position = new_position - 26
            new_letter = alphabet[new_position]
        elif letter.isnumeric():
            letter = letter
            print(letter)
        elif letter == " " or letter == "," or letter == "." or letter == ";" or letter == ":":
            letter = letter
            print(letter)
        else:
            print("Error in message please try a different message")
    print(new_message)
    print()
But its just printing blank space, can someone help me with the reason it;s doing this?
Reply


Messages In This Thread
Help with getting sub-program to print text - by djwilson0495 - Aug-16-2020, 04:21 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Print text with big font and style tomtom 6 21,313 Aug-13-2024, 07:26 AM
Last Post: yazistilleriio
  How to Randomly Print a Quote From a Text File When User Types a Command on Main Menu BillKochman 12 4,815 Apr-12-2024, 11:51 AM
Last Post: deanhystad
  Start print a text after open an async task via button Nietzsche 0 1,229 May-15-2023, 06:52 AM
Last Post: Nietzsche
  Saving the print result in a text file Calli 8 4,509 Sep-25-2022, 06:38 PM
Last Post: snippsat
  saving and loading text from the clipboard with python program MaartenRo 2 3,081 Jan-22-2022, 05:04 AM
Last Post: MaartenRo
  UnicodeEncodeError caused by print when program runs from Popen SheeppOSU 5 5,016 Jan-13-2022, 08:11 AM
Last Post: SheeppOSU
  read terminal text from running program AArdvark_UK 2 2,785 Aug-27-2020, 12:43 PM
Last Post: AArdvark_UK
  Want to print each iteration of factorial program sbabu 10 6,637 Jan-09-2020, 07:25 AM
Last Post: perfringo
  Print to Text file in Python 3 iteachpc 2 3,089 May-02-2019, 04:38 AM
Last Post: perfringo
  Why does function print require bracket for text? richardm55 2 4,114 May-23-2018, 07:30 PM
Last Post: buran

Forum Jump:

User Panel Messages

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