Four and Seven | PrepBytes please help

Here's my code in Python


def sol(s): 
	a, b = 0, 0
# 	you've to write the given number in the form of 
#  n = 4*a + 7*b (it is obvious that the solution will contain all 4's as prefix and
#  7's as suffix)

	while (s > 0): 
		if (s % 7 == 0):
			b += 1
			s -= 7
		elif (s % 4 == 0): 
			a += 1
			s -= 4
		else: 
			a += 1
			s -= 4

	ans = "" 
	if (s < 0): 
		ans = "-1"
		return ans 
	
	
	ans += "4" * a 
	ans += "7" * b 
	
	return ans 
s = int(input())
print(sol(s))

Thank you so much @yashdhiman