0
[Solved]My approach on "Gapful numbers" problem.
I am not sure whether.. my approach is good or not. But any help will be appreciated. Thank you https://code.sololearn.com/c24sH0CNDKNk/?ref=app
13 Réponses
+ 1
Gapful Numbers: You can refer this codehttps://code.sololearn.com/cbmnK71jbl9f/?ref=app
+ 1
try:
num=input()
assert (abs(int(num))>=100)
divisor=num[0]+num[-1]
if abs(int(num))%int(divisor )==0:
print(num,"is a gapful number")
else:
print(num,"is not a gapful number")
except(ValueError,AssertionError):
print("input must be integer atleast 3 digit long")
+ 1
Sheikh Hafijul Ali
I saw SOLVED, but my code may help you
https://code.sololearn.com/cDrwI0cli1jp/?ref=app
0
Your approach is not good
0
suael Where is the problem.? is there any input that breaks my program?
0
Problem 1:Gapful numbers not need to be always 3 digit number for example 1001 and -1001 are gapful numbers.. so your assert should be assert(abs(int(num))>100)..
0
suael okay.. missed that part thank you.
0
i would say a good approach is to except value error and assertion error incase user enter a chaarcter string
0
suael have a look again on my code
0
Yes, indeed i should, but...
0
There is builtin abs function in python ..see above code ..
0
yes, there is.. but.. my code would require.. much more changes to use that way...
i would find it difficult to print the divisor in my code.. and finally the initial input...
0
this is not much change;.just make sure u make proper indentation for try and except