Hi @Xuan.
I think you might be overthinking this level.
The mod40() function should be exactly the same as the mod30 function but with 40 instead of 30.
They should be the same, because they both do the same thing:
# This function returns a value from 0 to 30 (0 <= n < 30)
--
# This function should return a value from 0 to 40 (0 <= n < 40)
They should be the same.
I hope this helps.