I'm working on a program that works like so:
It asks for 2 inputs at once from the user, both of them are strings. If 2 strings are given, it prints "Yes". If only one string is given, it assumes the other one as "1" and prints "Maybe". If nothing is given, it prints "No".
The problem is that it doesn't accept nothing for an answer. If I type in only one string or nothing at all, it returns an error.
"ValueError: not enough values to unpack (expected 2, got 1/0)" How do I get around this?
Here is my code:
str1, str2 = input("Enter two values: ").split()
if str1 == "" and str2 == "":
print("No")
elif str1 == str() and str2 == "":
str2 = "1"
print("Maybe")
else: print("Yes")
Note- This will work only if some input is given if someone hit the enter without input the error raises
Code:-
Output:-
#Testcase1 when str1 and str2 both input given
#Tescase2 when str1 input given
#Testcase3 when no input given
To resolve this error ->