Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
test interable if len == 2
#5
because Skaperen wants exactly len 2:
if len(my_elements) != 2:
    raise IndexError('Iterable must have 2 elements')
or

assert len(my_elements) == 2, 'Iterable must have 2 elements.'
If you can't explain it to a six year old, you don't understand it yourself, Albert Einstein
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs

Reply


Messages In This Thread
test interable if len == 2 - by Skaperen - Jan-10-2020, 01:19 AM
RE: test interable if len == 2 - by buran - Jan-10-2020, 02:39 AM
RE: test interable if len == 2 - by Skaperen - Jan-10-2020, 04:00 AM
RE: test interable if len == 2 - by DeaD_EyE - Jan-10-2020, 09:08 AM
RE: test interable if len == 2 - by buran - Jan-10-2020, 09:26 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  How to test and import a model form computer to test accuracy using Sklearn library Anldra12 6 3,291 Jul-03-2021, 10:07 AM
Last Post: Anldra12
  How to write test cases for a init function by Unit test in python? binhduonggttn 2 3,208 Feb-24-2020, 12:06 PM
Last Post: Larz60+
  How to write test cases by Unit test for database configuration file? binhduonggttn 0 2,626 Feb-18-2020, 08:03 AM
Last Post: binhduonggttn

Forum Jump:

User Panel Messages

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