Originally Posted by
linttastic
---------- Post added at 10:44 PM ---------- Previous post was at 10:44 PM ----------
Ok so I tried adding another tab to those lines, but the code didnt run. When I moved it back again to where I had it, I was able to run the code, but still showing 'Minimum is' as none. Is the problem with my line 11 since that's where the 'Minimum is' comes from? It's just weird to me since it looks just the same as the 'Maximum is' string and that one printed correctly
Okay so there's two big problems here still.
1) Your TRY and EXCEPT are malformed. What you've done is this:
Code:
block 1: TRY
block 1-1: num = int(num)
block 2: IF#1
block 2-1: IF #1 is true, do this
block 3: IF#2
block 3-1: IF #2 is true, do this
block 4: EXCEPT
block 4-1: EXCEPT for the TRY command before
You need to move the BLOCK 4 under BLOCK 1 because that EXCEPT is not really registering correctly and your structure is just wrong.
Two ways to fix the structure are:
#1
Code:
block 1: TRY
block 1-1: num = int(num)
block 2: EXCEPT
block 2-1: EXCEPT for the TRY command before
block 3: IF#1
block 2-1: IF #1 is true, do this
block 4: IF#2
block 3-1: IF #2 is true, do this
#2
Code:
block 1: TRY
block 1-1: num = int(num)
block 1-2: IF#1
block 1-2-1: IF #1 is true, do this
block 1-3: IF#2
block 1-3-1: IF #2 is true, do this
block 2: EXCEPT
block 2-1: EXCEPT for the TRY command before
2) 2nd problem. Different programming languages deal with values "None"/null/""/undefined etc differently. In the case of Python, your IF#2 is never being run, because what's happening is that the value of "None" is always lower than no matter any other value you have. To add on to this a bit more, in Python any positive number value I know for a fact will be registered as a higher "value" than "None" which is why you don't need to explicitly do "largest = num" in the code below. I haven't tested enough to see if a negative number will still register as a higher "value" than "None" though, you'll have to test that and let me know hah.
So you need to add somewhere after num = int(num) and before your IF#2 the following:
Code:
if smallest is None:
smallest = num
I am happy to assist with anything more haha, I think if you make these changes your code will be almost there, it should give you the correct result but there are still things in there which I would have done differently