I
I
Ivan2014-11-11 08:30:32
Python
Ivan, 2014-11-11 08:30:32

Where is the correct place to enter an intermediate variable in Python?

There is a task: from the three variables entered, select the smallest one and display it on the screen. There is a piece of code when you run it, enter three numbers 1, 2 and 3, as a result 1 is displayed, run again enter 123, 5 and 9, 1 is displayed. There is a suspicion that I am incorrectly entering an intermediate variable and it does not take values ​​there.
Here is the code itself:

a=int(input())
b=int(input())
c=int(input())
if a<b and a<c:
    n=a
    if b<a and b<c:
        n=b
        if c<a and c<b:
            n=c
print(n)

Answer the question

In order to leave comments, you need to log in

2 answer(s)
R
Rostislav Grigoriev, 2014-11-11
@muller_johann

a=int(input())
b=int(input())
c=int(input())
print(min([a, b, c]))

A
Alexander, 2014-11-13
@Survtur

You have one if inside another. They must all be on the same level.
You will generally get an exception if you enter 123, 5 and 9 on the first run.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question