Need help! Code picks up on last digit of maximum #

Okay so I’ve racked my brain here but I’m having trouble with this code. Trying to pick up on the maximum number and minimum number of a user input number set. For some reason this code is only picking up on the last digit of whatever number I input. For example; if I input 22 and 7, it will say the minimum is 2 and max is 7. Doesn’t notice the first digit of “22” at all. Not sure why this is happening.

Hi and welcome to the forum!

It’s best to post the code instead of a screenshot.

It looks like you are iterating over the string num instead of using the integer fval.

Ah okay, my mistake I’m new here and also very new to coding. I tried to replace ‘num’ with fval in lines 12 and 17 but ended up with a traceback. I’m still trying to put together the conceptual basis of all this so I apologize if my questions are very basic etc.

You don’t need to use a for loop (for value in num) if you use fval directly.

Ah! Got it all sorted thanks so much for the help

1 Like