Python Forum
Thread Rating:
  • 2 Vote(s) - 3 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Recursivity - Problem
#3
+1 to nilamo requesting the whole error, but I felt generous and ran the code:
Error:
Traceback (most recent call last): File "<stdin>", line 1, in <module> File "<stdin>", line 9, in deepconcat File "<stdin>", line 11, in deepconcat File "<stdin>", line 9, in deepconcat File "<stdin>", line 9, in deepconcat File "<stdin>", line 9, in deepconcat File "<stdin>", line 11, in deepconcat File "<stdin>", line 9, in deepconcat File "<stdin>", line 11, in deepconcat File "<stdin>", line 9, in deepconcat File "<stdin>", line 9, in deepconcat File "<stdin>", line 9, in deepconcat TypeError: can only concatenate str (not "list") to str
When I started digging into your code I realized that you're returning within a loop such that the loops is misleading, you only ever look at the first element (for input composed only of strings and lists). I would suggest that you either (1) get rid of that loop or (2) make the loop not return on the first iteration. I think once you do that that your code will be more clear and easier for you and us to debug.
Reply


Messages In This Thread
Recursivity - Problem - by SupaFlamme - Jan-14-2019, 09:48 PM
RE: Recursivity - Problem - by nilamo - Jan-14-2019, 10:10 PM
RE: Recursivity - Problem - by micseydel - Jan-14-2019, 11:35 PM
RE: Recursivity - Problem - by scidam - Jan-15-2019, 12:33 AM
RE: Recursivity - Problem - by micseydel - Jan-15-2019, 12:57 AM
RE: Recursivity - Problem - by scidam - Jan-15-2019, 01:15 AM
RE: Recursivity - Problem - by perfringo - Jan-15-2019, 09:49 AM

Forum Jump:

User Panel Messages

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