You are given an integer N. You need to convert all zeroes of N to 5. 
Example 1:
Input:
N = 1004
Output: 1554
Explanation: There are two zeroes in 1004
on replacing all zeroes with "5", the new
number will be "1554".
Example 2:
Input:
N = 121
Output: 121
Explanation: Since there are no zeroes in
"121", the number remains as "121".
Your Task:
Your task is to complete the function convertFive() which takes an integer N as an argument and replaces all zeros in the number N with 5. Your function should return the converted number.
Expected Time Complexity: O(K) where K is the number of digits in N
Expected Auxiliary Space: O(1)
Constraints:
1 <= n <= 10000

Source: geeksforgeeks | Difficulty: EASY
Tags: Data structures

Mathematics

Starter code: # Function should return an integer value

def convertFive(n):

    # Code here

Solutions:
def convertFive(n):
	string = str(n)
	s = ''
	for i in string:
		if int(i) == 0:
			s += str(5)
		else:
			s += i
	return int(s)


def convertFive(n):
	a = str(n)
	L = [int(x) for x in a]
	for i in range(len(L)):
		if L[i] == 0:
			L[i] = 5
	b = ''
	for i in range(len(L)):
		b = b + str(L[i])
	return b


def convertFive(n):
	n = str(n)
	a = n.replace('0', '5')
	return a


def convertFive(n):
	strings = str(n)
	st = strings.replace('0', '5')
	return int(st)


def convertFive(n):
	K = str(n)
	y = K.replace('0', '5')
	return y


def convertFive(n):
	s = list(str(n))
	for i in range(len(s)):
		if s[i] == '0':
			s[i] = '5'
	d = ''.join(s)
	d = int(d)
	return d


def convertFive(n):
	x = str(n)
	y = x.replace('0', '5')
	return y


def convertFive(n):
	s = str(n)
	x = s.replace('0', '5')
	return int(x)


def convertFive(n):
	n = str(n)
	answer = ''
	for i in range(len(n)):
		if n[i] == '0':
			answer += '5'
		else:
			answer += n[i]
	return int(answer)


def convertFive(N):
	str_N = str(N)
	str_N = str_N.replace('0', '5')
	new_N = int(str_N)
	return new_N


def convertFive(n):
	str1 = str(n)
	for i in range(len(str1)):
		if str1[i] == '0':
			str1 = str1.replace(str1[i], '5')
		else:
			continue
	return str1


def convertFive(n):
	t = ''
	for i in str(n):
		if i == '0':
			t += '5'
		else:
			t += i
	return t


def convertFive(n):
	s = str(n)
	m = s.replace('0', '5')
	return m


def convertFive(n):
	a = []
	for i in str(n):
		if i == '0':
			a.append('5')
		else:
			a.append(i)
	return int(''.join(a))


def convertFive(n):
	result = 0
	multiply = 1
	while n // 10 > 0:
		remainder = n % 10
		if remainder == 0:
			result = result + 5 * multiply
		else:
			result = result + remainder * multiply
		multiply *= 10
		n = int(n / 10)
	if n == 0:
		result = result + 5 * multiply
	else:
		result = result + n * multiply
	return result


def convertFive(n):
	s = str(n)
	c = s.count(str(0))
	for i in range(c):
		s = s.replace(str(0), str(5))
	return int(s)


def convertFive(n):
	k = str(n)
	return int(k.replace('0', '5'))


def convertFive(n):
	s = n
	count = 0
	while s > 0:
		s = s // 10
		count += 1
	new_number = n
	for i in range(0, count):
		rem = n % 10
		if rem == 0:
			new_number = new_number + 5 * 10 ** i
		n = n // 10
	return new_number


def convertFive(n):
	l = []
	while n > 0:
		last = n % 10
		if last == 0:
			l.append(5)
		else:
			l.append(last)
		n = n // 10
	l1 = l[::-1]
	str1 = ''
	for i in l1:
		str1 += str(i)
	return str1


def convertFive(n):
	s = ''
	while n:
		dig = n % 10
		if dig == 0:
			s += '5'
		else:
			s += str(dig)
		n = n // 10
	s = s[::-1]
	return s


def convertFive(n):
	a = str(n)
	a = a.replace('0', '5')
	b = int(a)
	return b


def convertFive(n):
	x = str(n)
	for i in x:
		x = x.replace('0', '5')
	return int(x)


def convertFive(n):
	lst = list(str(n))
	for i in range(len(lst)):
		if lst[i] == '0':
			lst[i] = '5'
	return ''.join(lst)


def convertFive(n):
	if 1 <= n <= 10000:
		number_as_string = str(n)
		modifide_string = ''
		for digits in number_as_string:
			if digits == '0':
				digits = '5'
				modifide_string += digits
			else:
				modifide_string += digits
		modifide_number = int(modifide_string)
		return modifide_number


def convertFive(n):
	a = str(n)
	ar = ''
	for i in a:
		if int(i) != 0:
			ar = ar + i
		else:
			ar = ar + '5'
	return int(ar)


def convertFive(n):
	n = str(n)
	n2 = n.replace('0', '5')
	n2 = int(n2)
	return n2


def convertFive(n):
	j = str(n)
	k = j.replace('0', '5')
	return k


def convertFive(n):
	stk = []
	ans = 0
	while n:
		stk.append(n % 10)
		n = n // 10
	while stk:
		ele = stk.pop()
		if ele == 0:
			ans = ans * 10 + 5
		else:
			ans = ans * 10 + ele
	return ans

def convertFive(n):
	if n == 0:
		return 0
	digit = n % 10
	if digit == 0:
		digit = 5
	return convertFive(n // 10) * 10 + digit


def convertFive(n):
	d = 0
	ans = 1
	total = 0
	n1 = n
	while n1 > 0:
		d = n1 % 10
		if d == 0:
			d = 5
		total = total + d * ans
		ans = ans * 10
		n1 = n1 // 10
	return total


def convertFive(n):
	n = str(n)
	result = ''
	for ch in n:
		if ch == '0':
			result += '5'
			continue
		result += ch
	return int(result)


def convertFive(n):
	temp = str(n)
	temp = temp.replace('0', '5')
	return temp


def convertFive(n):
	num_str = str(n)
	new_str = num_str.replace('0', '5')
	new_num = int(new_str)
	return new_num


def convertFive(n):
	n = [x for x in str(n)]
	for i in range(len(n)):
		if n[i] == '0':
			n[i] = '5'
	num = ''.join(n)
	return int(num)


def convertFive(n):
	n = str(n)
	m = n
	for i in n:
		if i == '0':
			m = n.replace(i, '5')
	return int(m)


def convertFive(n):
	a = str(n)
	c = a.replace('0', '5')
	return int(c)


def convert(n):
	if n == 0:
		return 0
	digit = n % 10
	if digit == 0:
		digit = 5
	return convert(n // 10) * 10 + digit

def convertFive(n):
	if n == 0:
		return 5
	else:
		return convert(n)


def convertFive(n):
	n_str = str(n)
	n_str = n_str.replace('0', '5')
	return int(n_str)


def convertFive(n):
	t = str(n)
	if '0' in t:
		return int(t.replace('0', '5'))
	else:
		return n


def convertFive(n):
	temp = 1
	sum = 0
	while n > 0:
		rem = n % 10
		n = n // 10
		if rem == 0:
			sum = sum * 10 + 5 * temp
		else:
			sum = sum * 10 + rem
	return int(str(sum)[::-1])


def convertFive(n):
	inputStr = str(n)
	output = ''
	for i in inputStr:
		if i == '0':
			i = '5'
		output = output + i
	return output


def convertFive(n):
	k = list(map(int, str(n)))
	for i in range(0, len(k)):
		if k[i] == 0:
			k.remove(0)
			k.insert(i, 5)
	res = int(''.join(map(str, k)))
	return res


def convertFive(n):
	st = str(n)
	return st.replace('0', '5')


def convertFive(n):
	list = []
	for i in str(n):
		list.append(i)
		for i in range(0, len(list)):
			if list[i] == '0':
				list[i] = '5'
		else:
			list[i] = list[i]
	return ''.join(list)


def convertFive(N):
	ans = 0
	i = 0
	while N:
		if N % 10 == 0:
			ans += 5 * 10 ** i
		else:
			ans += N % 10 * 10 ** i
		N //= 10
		i += 1
	return ans


def convertFive(N):
	ans = 0
	while N:
		if N % 10 == 0:
			ans = ans * 10 + 5
		else:
			ans = ans * 10 + N % 10
		N //= 10
	return int(str(ans)[::-1])


def convertFive(n):
	r = str(n)
	t = r.replace('0', '5')
	final = int(t)
	return final


def convertFive(n):
	num = str(n)
	num2 = ''
	char = '5'
	for i in num:
		if i == '0':
			num2 = num2 + char
		else:
			num2 = num2 + i
	return num2


def convertFive(n):
	array = str(n)
	new_array = ''
	for i in range(len(array)):
		if array[i] == '0':
			new_array += '5'
		else:
			new_array += array[i]
	new_num = int(new_array)
	return new_num


import re

def convertFive(n):
	n_str = str(n)
	a = n_str.replace('0', '5')
	return int(a)


def convertFive(n):
	S = str(n)
	K = S.replace('0', '5')
	return K


def convertFive(n):
	list1 = str(n)
	for i in list1:
		if i == '0':
			list1 = list1.replace('0', '5')
	list2 = int(list1)
	return list2


def convertFive(n):
	s1 = str(n)
	return s1.replace('0', '5')