Python Forum
Why won't this user created function work?
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Why won't this user created function work?
#1
This is the code I wrote, but when it prints the message at the end, it prints the original input as if it had not gone through the string function. What's the problem?



message=str(raw_input("Enter the encoded string: "))
message=message.lower()

def strip(string):
    stripped_message=""
    for i in range(0,len(string)):
        character=ord(string[i:i+1])
        if character in range(97,123):
            stripped_message+=chr(character)
    return stripped_message


strip(message)
print message
Reply


Messages In This Thread
Why won't this user created function work? - by Evyeniarocks - Feb-26-2018, 01:28 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  print doesnt work in a function ony 2 329 Mar-11-2024, 12:42 PM
Last Post: Pedroski55
Information How to take url in telegram bot user input and put it as an argument in a function? askfriends 0 1,137 Dec-25-2022, 03:00 PM
Last Post: askfriends
  I dont know why my function won't work? MehHz2526 3 1,216 Nov-28-2022, 09:32 PM
Last Post: deanhystad
  User-defined function to reset variables? Mark17 3 1,690 May-25-2022, 07:22 PM
Last Post: Gribouillis
  Definitions in User-Created Functions and For Loops new_coder_231013 6 2,140 Dec-29-2021, 05:51 AM
Last Post: ndc85430
  time function does not work tester_V 4 3,091 Oct-17-2021, 05:48 PM
Last Post: tester_V
  Exit function from nested function based on user input Turtle 5 2,956 Oct-10-2021, 12:55 AM
Last Post: Turtle
  write new function or change the old one to work "smartter? korenron 3 2,014 Aug-09-2021, 10:36 AM
Last Post: jamesaarr
  string function doesn't work in script ClockPillow 3 2,442 Jul-13-2021, 02:47 PM
Last Post: deanhystad
  Why does unpickling only work ouside of a function? pjfarley3 5 3,479 Dec-24-2020, 08:31 AM
Last Post: pjfarley3

Forum Jump:

User Panel Messages

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