Python exception handling question

Asked 2 years ago, Updated 2 years ago, 55 views

num1, num2 = input().split() created a code that receives num1 and num2 as this code. I'm leaving a question because I don't know how to make a condition when I try to print out the phrase "error" if I type in more than two without doing any input.

python exception

2022-09-20 19:41

1 Answers

raw_input_text = input()
splt = list(raw_input_text.split())
if len(splt) == 2:
  num1, num2 = splt
else:
  # Get input again.


2022-09-20 19:41

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.