Python Forum
position of shortest string
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
position of shortest string
#1
Hello!
I have to create a function that takes as a parameter a list of strings. I need my function to return a number which is the position of the string with the shortest length.
I have succesfully created the function that finds the shortest string:
def g(x):
    return min(x, key=len)
But I can't figure a second function to return the position of this string.

Note: I must not use for, while
Yoriz write Mar-17-2022, 12:48 PM:
Please post all code, output and errors (in their entirety) between their respective tags. Refer to BBCode help topic on how to post. Use the "Preview Post" button to make sure the code is presented as you expect before hitting the "Post Reply/Thread" button.
Reply


Messages In This Thread
position of shortest string - by Ali_ - Mar-17-2022, 11:07 AM
RE: position of shortest string - by Coricoco_fr - Mar-17-2022, 12:03 PM
RE: position of shortest string - by DeaD_EyE - Mar-17-2022, 03:48 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Shortest path from s to t using python nkiki 9 920 Jan-28-2024, 05:58 PM
Last Post: Gribouillis
  Finding and storing all string with character A at middle position Pippi 2 2,759 Jan-20-2019, 08:23 AM
Last Post: Pippi
  Python Shortest Path python_snake 1 4,460 Mar-14-2017, 06:36 PM
Last Post: Larz60+

Forum Jump:

User Panel Messages

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