so far my code working perfectly as long as my first element is single-letter input but somehow value is not assigning to a variable when I input multiple letters to the first element
I just want to understand why the code is not assigning value when the first element is double or multiple letters?
Code:
date=input("Enter the date: ")
if date.find('-')==True:
dd,mm,yy=date.split('-')
elif date.find('/')==True:
dd,mm,yy=date.split('/')
else:
print('Incorrect Input',date)
print(dd,mm,yy)
Output Case 1:
Enter the date: 0-0-0
0 0 0
Output Case 2:
Enter the date: s/ss/ssss
s ss ssss
Output Case 3:
Enter the date: 10-10-10
Incorrect Input 10-10-10
Traceback (most recent call last):
File "C:**********", line 8, in <module>
print(dd,mm,yy)
NameError: name 'dd' is not defined
Output Case 4:
Enter the date: ss/sss/ss
Incorrect Input ss/sss/ss
Traceback (most recent call last):
File "C:**********", line 8, in <module>
print(dd,mm,yy)
NameError: name 'dd' is not defined
question from:
https://stackoverflow.com/questions/65896303/understandings-of-split-variable-assignation-in-if-statement 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…