Is there any other way for Python 3 to write a conditional expression that does not match any of the multiple strings (the state that the application keeps) short, other than the if statement below?
status='status_invalid'
if(status!='status_1') and(status!='status_2') and(status!='status_3'):
print('invalid status')
If the string comparison is a simple full-text match, I think you can use not in
.
status='status_invalid'
if status not in ['status_1', 'status_2', 'status_3']:
print('invalid status')
712 When building Fast API+Uvicorn environment with PyInstaller, console=False results in an error
542 Unable to install versioned in Google Colab
546 Understanding How to Configure Google API Key
548 rails db:create error: Could not find mysql2-0.5.4 in any of the sources
538 Uncaught (inpromise) Error on Electron: An object could not be cloned
© 2024 OneMinuteCode. All rights reserved.