Write a program that prompts the user to enter a two-digit integer .
This was the question and I tried to work it like this unsuccessfully.
def main():
# Prompt user to enter integer
numb1 = int(input('Enter a two digit integer '))
# Verify integer entered is correct before continuing
if len(numb1)!= 2:
print(f'Something is wrong with the first input. Try again')
# If number entered is correct get a second number
elif len(numb1) == 2:
numb2 = int(input('Enter another DIFFERENT two-digit integer '))
def main():
# Prompt user to enter integer
numb1 = int(input('Enter a two digit integer '))
# Verify integer entered is correct before continuing
if len(numb1)!= 2:
print(f'Something is wrong with the first input. Try again')
# If number entered is correct get a second number
elif len(numb1) == 2:
numb2 = int(input('Enter another DIFFERENT two-digit integer '))
# Verify new number fits parameters
if len(numb2)!= 2:
print(f'Something is wrong with the second input. Try again')
# Sort and display results
# Use subtraction to see how greater a number is from the other
else:
if numb1 > numb2:
print(f'{numb1} is larger than {numb2} by {numb1 - numb2}')
elif numb2 > numb1:
print(f'{numb2} is larger than {numb1} by {nuumb2 - numb1}')
main()
I’ve edited your post for readability. When you enter a code block into a forum post, please precede it with a separate line of three backticks and follow it with a separate line of three backticks to make it easier to read.
You can also use the “preformatted text” tool in the editor (</>) to add backticks around text.
since this was the prompt i thought doing it this way would work:
Write a program that prompts the user to enter a two-digit integer . If the user’s input is acceptable, prompt the user to enter another, DIFFERENT two-digit integer
def main():
# Prompt user to enter integer
numb1 = int(input('Enter a two digit integer '))
# Verify integer entered is correct before continuing
if numb1 > 99 and numb1 < 10:
print(f'Something is wrong with the first input. Try again')
# If number entered is correct get a second number
else:
if numb1 < 100 and numb1 > 9:
numb2 = int(input('Enter another DIFFERENT two-digit integer ')
# Verify new number fits parameters
if numb2 = numb1 and numb2 >99 and numb2 < 10:
print(f'Something is wrong with the second input. Try again')
# Sort and display results
# Use subtraction to see how greater a number is from the other
else:
if numb1 > numb2:
print(f'{numb1} is larger than {numb2} by {numb1 - numb2}')
elif numb2 > numb1:
print(f'{numb2} is larger than {numb1} by {nuumb2 - numb1}')
main()