How to take in multiple numbers as inputs in Python?

Правка en2, от ManGeo, 2021-11-26 17:55:00

This is a classic case which we encounter in the world of programming.

Different languages provide various methods to undertake this operation.

Well in my case, I believe that Python provides a very easy method to undertake this:

CASE-1:

A primitive way arises when the number of inputs are known like 3 innputs,

Then we may use,

Code:

a, b, c = map(int,input().split())

CASE-2:

What about the case, when number of inputs is unknown?

You might be familiar with the 'sort()' built- in function. Well that comes handy here.

Code:

a = list(map(int,input().split()))

a.sort()

Here 'sort()' gives our task a nice outlook too.

Well, hope you might have learnt something new today. I know many of you might already be familiar with it but it is always helpful if you have a glance at things at which you might be perfect too.

История

 
 
 
 
Правки
 
 
  Rev. Язык Кто Когда Δ Комментарий
en2 Английский ManGeo 2021-11-26 17:55:00 2 Tiny change: 'plit()))\na.sort()' -> 'plit()))\n\na.sort()'
en1 Английский ManGeo 2021-11-26 17:53:55 936 Initial revision (published)