Posted on:

09 Jun 2023

0

Alternative soultion for question #1 - using while & for loop, if condition , max, min

num1 = int(input('Please enter a number between 1-100:> '))
num2 = int(input('Please enter a number between 1-100:> '))

while num1 <= 1 or num2 <= 1 or num1 >= 100 or num2 >= 100 or num1 == num2:
print('please try again. Numbers must be different values between 1 and 100.')
num1 = int(input('Please enter a number between 1-100:> '))
num2 = int(input('Please enter a number between 1-100:> '))

x = []
statement = num1 > 1 and num2 > 1 and num1 < 100 and num2 < 100 and num1 != num2
if statement:
min_val = min(num1, num2)
max_val = max(num1, num2)
for i in range(min_val, max_val + 1):
x.append(min_val)
min_val += 1
print (x)

0 answers ( 0 marked as helpful)

Submit an answer