You're fed up about changing the version of your software manually. Instead, you will create a little script that will make it for you.

# Exercice

Create a function `nextVersion`, that will take a string in parameter, and will return a string containing the next version number.

For example:

# Rules

All numbers, except the first one, must be lower than 10: if there are, you have to set them to 0 and increment the next number in sequence.

You can assume all tests inputs to be valid.

Difficulty: EASY
Starter code: def next_version(version):
	

Solutions:
def next_version(version):
	ns = version.split('.')
	i = len(ns) - 1
	while i > 0 and ns[i] == '9':
		ns[i] = '0'
		i -= 1
	ns[i] = str(int(ns[i]) + 1)
	return '.'.join(ns)


def next_version(version):
	tab = list(map(int, version.split('.')))
	for x in range(1, len(tab) + 1):
		if tab[-x] is 9 and x != len(tab):
			tab[-x] = 0
		else:
			tab[-x] += 1
			break
	return '.'.join(list(map(str, tab)))


def next_version(version):
	if version.count('.') == 0:
		return str(int(version) + 1)
	elif int(version[-1]) < 9:
		return version[0:-1] + str(int(version[-1]) + 1)
	else:
		return next_version(version[0:-2]) + '.0'


def next_version(version):
	vs = list(map(int, version.split('.')))
	for i in range(len(vs) - 1, -1, -1):
		vs[i] += 1
		if vs[i] < 10:
			break
		if i:
			vs[i] %= 10
	return '.'.join(map(str, vs))


import re
from itertools import zip_longest

def next_version(version):
	(s, n) = re.subn('\\.', '', version)
	return ''.join([b + a for (a, b) in zip_longest('{:0{}}'.format(int(s) + 1, len(s))[::-1], '.' * n, fillvalue='')][::-1])


def next_version(version):
	if '.' not in version:
		return str(int(version) + 1)
	v = [i for i in version.split('.')]
	minor_version = False
	for index in reversed(list(range(len(v)))):
		if index == len(v) - 1:
			if int(v[index]) < 9:
				v[index] = str(int(v[index]) + 1)
				return '.'.join(v)
			else:
				minor_version = True
				v[index] = '0'
				continue
		if minor_version:
			v[index] = str(int(v[index]) + 1)
			if int(v[index]) != 10 or index == 0:
				return '.'.join(v)
			else:
				minor_version = True
				v[index] = '0'
				continue


def next_version(version):
	(carry, minors) = (1, [])
	for (i, n) in list(enumerate(version.split('.')))[::-1]:
		(carry, n) = divmod(int(n) + carry, 10 if i else int(n) + 2)
		minors.append(str(n))
	return '.'.join(minors[::-1])


def next_version(version):
	print(version)
	array_version = version.split('.')
	last_index = len(array_version) - 1
	start = 0
	add_value = 1
	while last_index >= 0:
		value_last_part_version = int(array_version[last_index]) + add_value
		if '0' in str(value_last_part_version):
			if last_index != 0:
				array_version[last_index] = str(0)
			else:
				array_version[last_index] = str(value_last_part_version)
			if len(str(value_last_part_version)) != 1:
				add_value = 1
			else:
				add_value = 0
		else:
			add_value = 0
			array_version[last_index] = str(value_last_part_version)
		last_index -= 1
	return '.'.join(array_version)


def next_version(version):
	(c, s) = (version.count('.') + 1, version.replace('.', ''))
	n = f'{int(s) + 1:0{len(s)}d}'[::-1]
	return ('.'.join((n[i] for i in range(c))) + n[c:])[::-1]