Q:

How do I reset to the beginning of the code after it runs?

After the code runs all the way for the first time, I want it to be able to go back to the first input and allow the user to input another word.
Do I need to create a for or while loop around the program?
import re    
import requests

search = input('What word are you looking for?: ')
first = re.compile(search)

source = input ('Enter a web page: ')
r = requests.get(source)
ar = r.text

mo = first.findall(ar)
print (mo)

print('Frequency:', len(mo))

A:

Yes, a loop is needed:
import re    
import requests

while True:
    search = input('What word are you looking for?: ')
    # per comment, adding a conditional stop point.
    if search == "stop":
        break

    first = re.compile(search)

    source = input ('Enter a web page: ')
    r = requests.get(source)
    ar = r.text

    mo = first.findall(ar)
    print (mo)

    print('Frequency:', len(mo))

