Python Forum
Passing string functions as arguments
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Passing string functions as arguments
#2
def transform_nth(str_in, n, transform):
    return ''.join([str_in[:n], transform(str_in[n]), str_in[n + 1:]])
 
name = transform_nth("dave", 2, str.upper)
print(name)
Clunk_Head likes this post
If you can't explain it to a six year old, you don't understand it yourself, Albert Einstein
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs

Reply


Messages In This Thread
RE: Passing string functions as arguments - by buran - Jun-15-2022, 04:49 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Problems passing arguments containing spaces to bash script and then on to python kaustin 6 8,963 Apr-03-2024, 08:26 PM
Last Post: deanhystad
  Passing writable arguments to functions. Assembler 11 3,506 Jan-15-2024, 11:32 PM
Last Post: sgrey
  TypeError: not enough arguments for format string MaartenRo 6 5,259 Jan-09-2022, 06:46 PM
Last Post: ibreeden
  Why Pass Functions as arguments? muzikman 14 8,573 Jan-18-2021, 12:08 PM
Last Post: Serafim
  redirect url_for passing arguments with the url Leon79 1 2,333 Jul-09-2020, 05:20 PM
Last Post: Leon79
  passing-arguments-from-one-script-to-another jacklee26 7 4,536 Apr-21-2020, 03:55 PM
Last Post: deanhystad
  Python 2.7 passing variables from functions zetto33 1 2,485 Mar-19-2020, 07:27 PM
Last Post: Larz60+
  MySQLdb._exceptions.ProgrammingError: not enough arguments for format string. farah97 0 4,253 Jan-22-2020, 03:49 AM
Last Post: farah97
  Accepting strings as arguments when slicing a string? (Ziyad Yehia on Udemy) Drone4four 4 5,112 Aug-23-2019, 07:59 PM
Last Post: Drone4four
  TypeError: not all arguments converted during string formatting RedSkeleton007 1 16,635 Jul-15-2018, 08:51 PM
Last Post: ichabod801

Forum Jump:

User Panel Messages

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