Python Forum
I'm getting a wrong answer don't know where the bug is
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
I'm getting a wrong answer don't know where the bug is
#2
maybe this

def smallest(a, b, c):
    smallest = a
 
    if b < smallest:
        smallest = b
    elif c < smallest and b > c:
        smallest = c
 
    return smallest
 
def largest(a, b, c):
    largest = a
 
    if b > largest and b > c:
        largest = b
    elif c > largest and b < c:
        largest = c
 
    return largest
 
x = int(input("Enter first number:"))
y = int(input("Enter second number:"))
z = int(input("Enter third number:"))
 
print()
 
smallest_integer = smallest(x, y, z)
largest_integer = largest(x, y, z)
 
print("The smallest is", smallest_integer)
print("The largest is", largest_integer)
Reply


Messages In This Thread
RE: I'm getting a wrong answer don't know where the bug is - by Axel_Erfurt - Jul-07-2019, 09:30 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Am I wrong or is Udemy wrong? String Slicing! Mavoz 3 2,699 Nov-05-2022, 11:33 AM
Last Post: Mavoz
  why don't i get the answer i want CompleteNewb 12 3,544 Sep-04-2021, 03:59 PM
Last Post: CompleteNewb
  I am getting the wrong answer, and not sure why riskeay 3 2,094 Nov-05-2020, 08:24 PM
Last Post: deanhystad
  Make the answer of input int and str enderfran2006 2 2,055 Oct-12-2020, 09:44 AM
Last Post: DeaD_EyE
  Keeps looping even after correct answer mcesmcsc 2 1,968 Dec-12-2019, 04:27 PM
Last Post: mcesmcsc
  python gives wrong string length and wrong character thienson30 2 3,071 Oct-15-2019, 08:54 PM
Last Post: Gribouillis
  How to answer subprocess prompt Monty 8 17,530 Feb-14-2018, 09:59 AM
Last Post: wavic

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020