DEV Community

Free Python Code
Free Python Code

Posted on

How to remove value from a tuple in Python

Hi 🙂🖐


myData = (1, 2, 3)

def remove_item(value, data):
    # convert tuple to list
    data = list(data)
    data.remove(value)
    return tuple(data)


print(remove_item(1, myData))
Enter fullscreen mode Exit fullscreen mode

result

(2, 3)
Enter fullscreen mode Exit fullscreen mode

Top comments (0)