Why is the console showing TypeError

#1

I am making a program where we can know whether we can form a string from two other strings.
The main string is s and the other two strings are part1 and part2.

Examples:

  suppose s = newspaper, part1 = newpa and part2 = sper
 
  part1 and part2 are the mergers of s

In this situation the console wil return True

Click here to see the source code

The problem is that for every input the output is False. Therefore, I would like to get help from the community to identify my mistake/mistakes so that I can rectify them and run them properly

THANK YOU

#2

The program feels unnecessary complex for its goal.

the big problem is here:

for (l, m) in zip(part1, part2):

you loop over part1 and part2, why? these variable still contain the original input (part1=Hello, part2=World), so this won’t go well.

shouldn’t you loop over list1 and list2?

anyway, i recommend you to execute your code here:

http://www.pythontutor.com/visualize.html#mode=display

might help you. It also might help you find the other bug which i won’t mention for now. Let me know if you need further help

1 Like