python intermediate 2026-11-17 को समाप्त

Compare version numbers

Package managers compare versions like 1.10.0 and 1.9.3. Write compare(a, b) that returns -1 if a is older, 1 if a is newer and 0 if they are equal.

  • Compare each dot-separated part as a number: 1.10 is newer than 1.9.
  • Missing parts count as zero: 1.2 equals 1.2.0.
  • Ignore a leading v: v2.0.1 equals 2.0.1.

Acceptance criteria

  • The tests at the bottom print All tests passed.

अब तक 0 लोगों ने हल किया।

python
एडिटरCtrl + Enter

            
        

जब टेस्ट "All tests passed" दिखाते हैं, तो चैलेंज इस ब्राउज़र में हल के रूप में चिह्नित हो जाता है।

अपना समाधान समीक्षा के लिए भेजें