Python Forum
Thread Rating:
  • 3 Vote(s) - 2 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Incorrect code
#11
>>> isinstance(input, type(print))
True
>>> isinstance(input, type(assert))
  File "<stdin>", line 1
    isinstance(input, type(assert))
                                ^
SyntaxError: invalid syntax
In py2, print() could be used like a function, but it wasn't.  Assert can be used like a function, but it isn't.
Reply
#12
I found the solution......
def ok(a, b, c):

    if abs(a - b) <= c or a * b >= 0:

        return True

    return False

  

  

def number(d, e):

    f = 0

    for i in range(len(d)-1):

        if not ok(d[i], d[i+1], e):

            f += 1
    return f
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  I am getting an incorrect average, and not sure why? What's wrong with my code? shirleylam852 8 4,660 Nov-20-2020, 05:32 AM
Last Post: deanhystad
  Return giving incorrect value Calingaladha 5 3,336 Oct-24-2018, 09:53 PM
Last Post: LeSchakal
  Writing incorrect passwords to a file till its correct garth 2 4,939 Feb-10-2017, 11:41 PM
Last Post: ichabod801

Forum Jump:

User Panel Messages

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