In general, don't use operator.add (e.g. +) to deal with strings. There's nothing particularly wrong with it, but it's good practice to use string formatting instead.
Try this instead:
last_octet = random.randint(0,255) # please use descriptive var names
IP_format = "{}.{}.{}.{}"
IP = IP_format.format(192,168,0,last_octet)
Your approach won't work because you're using append on a string. append is (generally considered to be) a method for a list to add to itself. If you'd like to use that method, you could do:
last_octet = random.randint(0,255)
IP_list = [192,168,0]
IP_list.append(last_octet) # IP_list is now [192,168,0,<random number>]
IP = ".".join(map(str,IP_list))
In that last line I use a combination of two functions you likely don't know about.
map takes two arguments, the first is a function (in this case str, e.g. str(192) --> "192") and the second is an iterable (in this case the list IP_list, but iterables are anything you can use a for loop on). It applies the function you give it to every element in the iterable, and leaves you with a DIFFERENT iterable in Python3 called a map object. In Python2, it returned a list.
".".join is explicitly calling str.join. It accepts an iterable as an argument (see above), and puts the str between each element of the iterable. ".".join(["192","168","0","255"]) gives you "192.168.0.255". This is possibly most often used by its alias in os.path, os.path.join which takes a set of arguments and puts the local path separator between each one, e.g. os.path.join("C:","Program Files","AdamSmith","locale","en-US","docs.html") would give you a string on Windows that's "C:\Program Files\AdamSmith\locale\en-US\docs.html" and on *nix that's C:/Program Files/AdamSmith/locale/en-US/docs.html"