[Solved] How to find the biggest values of (three values) without using looping them? [Python] [duplicate]


Add all of your variables to a list and then you can use the max function like so max(lista)

num1 = int(input('What is the first number?: '))
num2 = int(input('What is the second number?: '))
num3 = int(input('What is the third number?: '))

lista = [num1, num2, num3]

biggest = max(lista)

print(f"{biggest} is the largest value.")
(xenial)vash@localhost:~/python/stack_overflow$ python3.7 max.py
What is the first number?: 10
What is the second number?: 3
What is the third number?: 8
10 is the largest value.

Just for a little bonus, didn’t include handling TypeErrors but want to give you some ideas where you can go with this little project:

while True:

    numbers = int(input("How many numbers would you like to enter: "))

    values = []

    for i in range(numbers):
        if i == numbers - 1:
            values.append(int(input(f"Enter 1 number: ")))
        else:
            values.append(int(input(f"Enter {numbers - i} numbers: ")))

    print(f"\nThe largest number entered was {max(values)}")
(xenial)vash@localhost:~/python/stack_overflow$ python3.7 max.py
How many numbers would you like to enter: 5
Enter 5 numbers: 10
Enter 4 numbers: 8
Enter 3 numbers: 29
Enter 2 numbers: 13
Enter 1 number: 22

The largest number entered was 29

solved How to find the biggest values of (three values) without using looping them? [Python] [duplicate]