0

My program keeps showing this error raw_input is not defined whenever I use raw_input:

import urllib
from bs4 import BeautifulSoup
url = raw_input('http://py4e-data.dr-chuck.net/known_by_Eqlaas.html: ')
count = int(raw_input("Enter count: "))
position = int(raw_input("Enter position:"))
for i in range(count):
    html = urllib.urlopen(url).read()
    soup = BeautifulSoup(html)

    tags = soup('a')
    s = []
    t = []
    for tag in tags:
        x = tag.get('href', None)
        s.append(x)
        y = tag.text
        t.append(y)

    print (s[position-1])
    print (t[position-1])
    url = s[position-1]
some_programmer
  • 3,268
  • 4
  • 24
  • 59
Silkcode
  • 1
  • 1
  • 3
    Does this answer your question? [What's the difference between \`raw\_input()\` and \`input()\` in Python 3?](https://stackoverflow.com/questions/4915361/whats-the-difference-between-raw-input-and-input-in-python-3) – Tomerikoo May 07 '20 at 13:47

2 Answers2

4

Starting with Python 3, raw_input() was renamed to input().

Roy
  • 1,612
  • 2
  • 12
  • 38
1

Since you are using python3, you have to replace

count = int(raw_input("Enter count: "))
position = int(raw_input("Enter position:"))

with

count = int(input("Enter count: "))
position = int(input("Enter position:"))
some_programmer
  • 3,268
  • 4
  • 24
  • 59