Make some inputs inside functions instead of main I'm very new to OOP, and I'm trying to do it correctly!
I have been doing a simple friendbook where you can add, remove and show the friends you have. However, I dont know if I should be satisfied or not with my code.

class Friendbook:

    listOfFriends = {}

    def __init__(self, name, lastname):
        self.name = name
        self.lastname = lastname

    def addFriend(self):
        self.listOfFriends[self.name] = self.lastname

    def showFriends(self):
        for firstname, lastname in self.listOfFriends.items():
            print(firstname, lastname)

    def removeFriend(self):
        removeName = input("Enter name to remove\n")
        del self.listOfFriends[removeName]


while True:

    print("1. Add Friend\n2. Showfriends\n3. RemoveFriend\n9. Quit\n")
    try:
        selectedOption = int(input())
        if selectedOption == 1:
            name = input("Enter firstname\n") #Can i move this to a function?
            lastname = input("Enter lastname\n") #Can i move this to a function?
            makeFriends = Friendbook(name, lastname)
            makeFriends.addFriend()
        elif selectedOption == 2:
            makeFriends.showFriends()
        elif selectedOption == 3:
            makeFriends.removeFriend()
        elif selectedOption == 9:
            break
        else:
            print("Not a valid option")
    except:
        print("Only integers allowed")


I'm happy with it except for the code related to selectedoption 1, can I do something to put it inside the function so it looks nicer?
What do you think about my code in general, appreciate feedback!
You are using classes wrong. With your class, you can never have two friend books, because each instance uses the classes mutable listOfFriends. (N.B.: A dictionary called listOf... is not very helpful).

Instead, have one FriendBook object, and let its methods take arguments:

class FriendBook:

    def __init__(self):
        self.friends = set()

    def add(self, firstname, lastname):
        self.friends.add((firstname, lastname))

    def remove(self, firstname, lastname):
        self.friends.remove((firstname, lastname))

    def __str__(self):
        return '\n'.join("{} {}".format(*name) for name in self.friends)


A few notes:


The friends are a set now (this assumes that no two friends share the same first and last name, already a better assumption than yours, which assumed that every friend had a unique last name). You could also make it a list, you would just have to change self.friends.add to self.friends.append.
The magic function __str__ allows simply calling print(fb), where fb is an instance of FriendBook, to print the full list of friends.
I made the names a bit easier. Note that Python has an official style-guide, PEP8, which recommends using PascalCase for classes and snake_case everywhere else.


For your main question, yes you can put these in a function:

def ask_name():
    first_name = input("Enter firstname\n")
    last_name = input("Enter lastname\n")
    return first_name, last_name


I would also slightly rewrite your main function, like this:

if __name__ == "__main__":
    fb = FriendBook()
    while True:
        print("1. Add Friend\n2. Show Friends\n3. Remove Friend\n9. Quit\n")
        try:
            option = int(input())
        except ValueError:
            print("Only integers allowed")
            continue
        if option == 1:
            fb.add(*ask_name())
        elif option == 2:
            print(fb)
        elif option == 3:
            fb.remove(*ask_name())
        elif option == 9:
            break
        else:
            print("Not a valid option")


Notes:


I wrapped it all in a if __name__ == "__main__" guard to allow importing this class from another script.
I use the defined function to ask for the names and use tuple unpacking to pass it to the methods.
I limited the scope of the try...except clause and made it more specific. Your current except covered everything, even, for example, the user pressing Ctrl+C. You should almost always avoid doing this.