import socket


def obtain_ip(state):
    """
    Method to get own ip address.
    Accepts: state which is an empty object from the udp_broadcast class
    Returns: ip address (string)
    """
    # gethostname() returns a string containing the hostname of the machine
    # gethostname() translates a host name to IPv4 address format
    state.my_ip = socket.gethostbyname(socket.gethostname())
    print("\nMy IP is:", state.my_ip, "\n")
    return state.my_ip