-2

Alright so I started learning python in my classes but I am very annoyed how you cannot declare variable types in python like other languages. What would be the best way to turn these strings into integers?

for lineNum, line in enumerate(sys.stdin):
if(lineNum == 0):
    xc, yc = eval(line)
    xc = int(xc)
    yc = int(yc)
elif(lineNum == 1):
    r = line
    r = int(r)
elif(lineNum == 2):
    x1, y1 = eval(line)
    x1 = int(x1)
    y1 = int(y1)
else:
    x2, y2 = eval(line)
    x2 = int(x2)
    y2 = int(y2)

1 Answers1

1

You cannot declare types in Python because Python is a dynamically typed programming language like Ruby, Smalltalk, Javascript, and many others as well. Dynamic languages have their own pros and cons, try to learn them.

int_number = int('99') # here you go as far as casting is concerned
hspandher
  • 15,934
  • 2
  • 32
  • 45