Files
cybr108/lab-01/r-1.3_scratch.py
T

31 lines
809 B
Python

#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Wed Sep 2 22:49:38 2026
@author: joseph
- The validation loop (which I just learned was called a try-except structure)
is printing every correctly formatted float as an invalid number. After digging
around with Spyder, I found PyLint code analysis, ran that, and found my syntax
error: having the colon directly after except on line 27 instead of after the
entire line.
"""
def minmax(*data):
ordered = sorted(data)
data = (ordered[0], ordered[-1])
print(data)
user_data = input('Enter any amount of numbers, separated by spaces: ')
list_data = user_data.split()
float_data = []
for x in list_data:
try:
float_data.append(float(x))
except ValueError:
print(f'{x} is an invalid number')
print(float_data)