How do I write a loop to repeat the code?

Create a function repeat and add your code in it. Then use while True to call it infinitely or for i in range(6) to call it 6 times:

import requests
def repeat():
  addr = input()
  vendor = requests.get('http://api.macvendors.com/' + addr).text
  print(addr, vendor)
while True:
  repeat()

Note that goto is not recommended in any language and is not available in python. It causes a lot of problems.

Leave a Comment