Random Version Number Generator

  • Share this:

Code introduction


This function takes the current version number as an argument and returns a new random version number. The version number format is X.Y.Z, where the Z part will be randomly incremented by a number between 1 and 10.


Technology Stack : Python

Code Type : Python Function

Code Difficulty : Intermediate


                
                    
def generate_random_version_number(current_version):
    import random
    import string

    def increment_version(version):
        parts = version.split('.')
        last_part = int(parts[-1])
        incremented_part = str(last_part + random.randint(1, 10))
        return '.'.join(parts[:-1] + [incremented_part])

    return increment_version(current_version)                
              
Tags: