find max, min character 1

find max, min character

t = input("your text>>")
min_char = t[0]
max_char = t[0]

for item in t:
    if itemmax_char:
      max_char = item

print(f"min_char: {min_char}")
print(f"max_char: {max_char}")

Here is what the above code is Doing:
1. We are taking the input from the user and storing it in a variable called t.
2. We are initializing two variables min_char and max_char with the first character of the string.
3. We are iterating through the string and comparing each character with the min_char and max_char.
4. If the character is less than min_char, we are updating min_char with that character.
5. If the character is greater than max_char, we are updating max_char with that character.
6. Finally, we are printing the min_char and max_char.

Similar Posts