Python Forum
Thread Rating:
  • 2 Vote(s) - 2.5 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Recursive function
#1
How to change this code to recursive code...

def search(myList, number):
    for i in myList:
        if i[0] == number:
            return i[1]
    return None



myList = [(5107261, 'Ernst'), (6524256, 'Arvo')]

number = 5107261

print(search(myList, number))
Reply
#2
We're not going to do your homework for you, what have you tried? Have you identified the basis and recursive cases?
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  "Plotting and Computation of Logistic Function by Using Taylor Series with Recursive canatilaa 1 1,806 May-13-2020, 04:01 PM
Last Post: jefsummers
  Recursive Function - Compare 2 lists, return the elements that don't exist in both KellyBaptist 1 5,220 Dec-23-2018, 10:10 AM
Last Post: Gribouillis
  Storing Minimum List of values from a recursive function sigsegv22 1 2,528 Sep-10-2018, 01:25 PM
Last Post: ichabod801
  Recursive function with a parameter MOH 0 2,051 Apr-30-2018, 09:39 PM
Last Post: MOH
  Recursive Function Fanki 2 2,996 Dec-06-2017, 11:40 AM
Last Post: gruntfutuk
  Recursive function need help Neural_oD 4 5,997 Aug-01-2017, 09:23 AM
Last Post: Neural_oD

Forum Jump:

User Panel Messages

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