Python Forum
Teacher (thrown in at the deep end - help)
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Teacher (thrown in at the deep end - help)
#6
Just use the second example. This is more pythonic and better to read.

if min_val <= current_val <= max_val:
    pass
This allows also current_val == min_val or current_val == max_val.
If the min/max value should be outside of the range, use the < operator instead.
Almost dead, but too lazy to die: https://sourceserver.info
All humans together. We don't need politicians!
Reply


Messages In This Thread
RE: Teacher (thrown in at the deep end - help) - by DeaD_EyE - May-22-2018, 01:08 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  which exception should be thrown for a sequence of the wrong length? Skaperen 1 915 Jan-06-2023, 04:13 AM
Last Post: deanhystad
  deep learning python Stevedas 1 1,770 Sep-26-2021, 08:32 AM
Last Post: Yoriz
  Pytest API Post call thrown errors pyseeker 4 3,776 Dec-08-2019, 04:53 PM
Last Post: pyseeker
  Invalid argument error thrown. pyseeker 4 8,733 Sep-10-2019, 07:03 PM
Last Post: pyseeker
  pytest fixture in conftest.py thrown error while in the test file runs OzzieOzzum 1 4,057 Jul-31-2018, 12:12 PM
Last Post: OzzieOzzum
  [split] Teacher (thrown in at the deep end - help) Mr90 2 3,075 May-23-2018, 02:04 PM
Last Post: DeaD_EyE
  Parse XML - how to handle deep levels/hierarchy dwill 8 9,729 Apr-17-2018, 04:17 PM
Last Post: dwill
  Exception not thrown in python3 ONEoo7 7 6,234 Apr-09-2017, 01:58 AM
Last Post: snippsat

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020