-1

I'm new to this but can anyone tell me what does this line mean?

capacity = int(input())
azro
  • 47,041
  • 7
  • 30
  • 65
  • 1
    You might want to explain what you didn't understand when you read the documentation of [`input`](https://docs.python.org/3/library/functions.html#input) and [`int`](https://docs.python.org/3/library/functions.html#int). BTW, do you really want answers for Python 2? Python 2 reached end of life over one year ago and that was announced over 10 years ago. – Matthias Apr 28 '21 at 07:39

2 Answers2

1

The input() function allows user input in the console.
But that input is a string and even if the user enters '343' you won't be able to use it as a number for mathematic operations.
So int() is a function that takes a string and returns the integer (whole number) represented by the string.
So you will use int(input()) when you want to get an input that can only be a number.
Tip: if the user enters random characters like 'abcd', the program will generate an error as those aren't numbers

S H
  • 331
  • 1
  • 13
0

int() changes a string to an integer. input() takes input as a string and int() convert it into an integer.