0

Here's what Ive figured out till now but I'm confused as to what I have to do next.

@d <= lnk.value:
TypeError: '<=' not supported between instances of 'int' and 'LinkNode'
4
  • 1
    What errors? Please include the full traceback. Commented Nov 1, 2018 at 22:00
  • In addition to what @roganjosh asked, please edit your question to include it there, not here in the comments. Commented Nov 1, 2018 at 22:00
  • Hey IneedHelpFellas! In case you're really new to python, the "Full Traceback" is the error report that shows up when you try to run the code. Posting this as part of your code can help us determine what is wrong. Commented Nov 1, 2018 at 22:11
  • Sorry, for the not adding that beforehand, just did Commented Nov 1, 2018 at 22:52

1 Answer 1

1

The error:

File "D:/insertionsort.py", line 21, in insert
    if lnk == None or val.value <= lnk.value:
TypeError: '<=' not supported between instances of 'int' and 'LinkNode'

Is telling you that when <= gets called, lnk.value is a LinkNode, which can't be compared with an int (which is what val.value is). In the line:

lnkNew = LinkNode(lnk, insert(val, lnk.rest))

You're setting lnkNew.value to lnk; it should be lnk.value.

Sign up to request clarification or add additional context in comments.

2 Comments

yes, that would work if the frozen was false, but in case of frozen to be true,i cant really change the lnk
@IneedHelpFellas I mean that when you build the new LinkNode, you should be using lnk.value to initialise value in lnkNew.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.