Python Forum
How can I return my list from a func?
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How can I return my list from a func?
#1
I have a list. I'm getting items that starting from number.
s = ['kdkkd', '1 america', 'wwww', '2 Russia', 'd333', '3England']
def get_title_list(a):
    for x in mylist:
        try:
            int(x[0])
            print(x)
        except ValueError:
            pass
get_title_list(s)
It works, but it doesn't work if I'm trying like this
s = ['kdkkd', '1 america', 'wwww', '2 Russia', 'd333', '3England']
def get_title_list(a):
    for x in mylist:
        try:
            int(x[0])
            return x
        except ValueError:
            pass
print(get_title_list(s))
I get one itme from s. How to return?
Reply


Messages In This Thread
How can I return my list from a func? - by Mike Ru - Oct-22-2018, 11:53 AM
RE: How can return my list from a func? - by buran - Oct-22-2018, 11:56 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  How do I calculate a ratio from 2 numbers and return an equivalent list of about 1000 Pleiades 8 15,439 Jan-05-2024, 08:30 PM
Last Post: sgrey
  How to output one value per request of the CSV and print it in another func? Student44 3 1,278 Nov-11-2022, 10:45 PM
Last Post: snippsat
  Need to parse a list of boolean columns inside a list and return true values Python84 4 2,036 Jan-09-2022, 02:39 AM
Last Post: Python84
  How to invoke a function with return statement in list comprehension? maiya 4 2,750 Jul-17-2021, 04:30 PM
Last Post: maiya
  Regular expression: return string, not list Pavel_47 3 2,452 Jan-14-2021, 11:49 AM
Last Post: Pavel_47
  Func Animation not displaying my live graph jotalo 0 1,523 Nov-13-2020, 10:56 PM
Last Post: jotalo
  Trying to write func("abcd") -> "abbcccdddd" omm 8 3,983 Oct-24-2020, 03:41 AM
Last Post: bowlofred
  Function to return list of all the INDEX values of a defined ndarray? pjfarley3 2 1,918 Jul-10-2020, 04:51 AM
Last Post: pjfarley3
  LDAP3 not return a list correctly? bazcurtis 0 2,615 Dec-23-2019, 04:20 PM
Last Post: bazcurtis
  call func from dict mcmxl22 3 2,820 Jun-21-2019, 05:20 AM
Last Post: snippsat

Forum Jump:

User Panel Messages

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