+ 16
Challange:. Duck Number!
A duck number is a number which contains 0 in it but should not contain 0 at the starting and in second position Examples: 1025 : not a duck number because it contains 0 in second position 0256: not a duck number because it contains 0 in First position position 1234: Not a duck number because it doesn't contain 0 123508: Duck number because it contain 0 but not in 1st and 2nd position Note:Number can be of any length entered by the user. Have fun and code!!🎉🎊
17 Respostas
+ 15
https://code.sololearn.com/WDBBn3Dy9nFj/?ref=app
+ 13
+ 11
Here's some Python
number = input("Enter a number: ")
dn = "0" in number and "0" not in number[:2]
print("{} is {}a duck number.".format(number, "" if dn else "not "))
https://code.sololearn.com/cqrPst1qLinK/#py
+ 10
https://code.sololearn.com/c4SW8VdZg2h0/?ref=app
+ 8
Here's my try :
https://code.sololearn.com/crneb7kAd0UJ/?ref=app
+ 6
https://code.sololearn.com/cu5IpShH5r1X/?ref=app
+ 6
you can try like this too in Java😊😊
https://code.sololearn.com/cp9O2bB5eoOs/?ref=app
+ 4
mine!
https://code.sololearn.com/cUvs9cDvzhGx/?ref=app
edit: for the first 5 minutes, code was not correct as i didn't read a line of challenge task, now it should be fixed...
+ 4
clean and simple https://code.sololearn.com/cr5fahd21tAl/?ref=app
+ 3
i think when reading numbers from left to right they are better read as strings.
https://code.sololearn.com/cJaq8259wm4c/?ref=app
+ 3
here is my piece of code..
https://code.sololearn.com/cNAL9KsMQQ84/?ref=app
+ 2
Here is my answer in Python : https://code.sololearn.com/cPycqRvL2dqQ/#py
+ 2
Here you go. Checks for valid input
https://code.sololearn.com/c5chySwe0oC4/?ref=app
+ 1
https://code.sololearn.com/cvq0AY5jkJPE/?ref=app