I'm new to python and I'm currently completing an project for school.
How would I proceed if I were to write a function named inputfunction()
that would work as follow:
var1, coordinates = inputfunction()
"enter var1": 0
"enter coordinates" (x,y): 0,1
>>> print(var1)
0
>>> print(coordinates)
[0, 1]
I really don't know where to start.
CodePudding user response:
Return the two different values as a tuple.
>>> def inputfunction() -> tuple[int, list[int]]:
... return (
... int(input('"enter var1": ')),
... [int(n) for n in input('"enter coordinates" (x,y): ').split(",")]
... )
...
>>> var1, coordinates = inputfunction()
"enter var1": 0
"enter coordinates" (x,y): 0,1
>>> print(var1)
0
>>> print(coordinates)
[0, 1]