Write a python code to extract the year from a string.
string = "This movie was released in 1980"
import re

string = "This movie was released in 1980"

# search for substring of 4 digits
result = re.search(r'\d{4}', string)

# print the year
if result:
    print(result.group())