+ 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!!🎉🎊

30th Aug 2017, 5:39 PM
Aditya
Aditya - avatar
17 Respostas
14th May 2018, 2:54 PM
Danijel Ivanović
Danijel Ivanović - avatar
+ 15
https://code.sololearn.com/WDBBn3Dy9nFj/?ref=app
30th Aug 2017, 5:47 PM
Burey
Burey - avatar
31st Aug 2017, 6:19 AM
Shamima Yasmin
Shamima Yasmin - avatar
+ 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
30th Aug 2017, 10:09 PM
David Ashton
David Ashton - avatar
+ 10
https://code.sololearn.com/c4SW8VdZg2h0/?ref=app
20th Sep 2017, 1:45 PM
Changed
Changed - avatar
1st Sep 2017, 10:39 PM
LukArToDo
LukArToDo - avatar
+ 6
https://code.sololearn.com/cu5IpShH5r1X/?ref=app
1st Sep 2017, 6:29 AM
hamletmun
hamletmun - avatar
+ 6
you can try like this too in Java😊😊 https://code.sololearn.com/cp9O2bB5eoOs/?ref=app
20th Sep 2017, 12:50 PM
GAWEN STEASY
GAWEN STEASY - avatar
30th Aug 2017, 7:12 PM
ysraelcon
ysraelcon - avatar
+ 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...
30th Aug 2017, 7:46 PM
Luca
Luca - avatar
31st Aug 2017, 8:30 AM
Nour Alhadi Mahmoud
Nour Alhadi Mahmoud - avatar
31st Aug 2017, 9:26 AM
Alex Gorbacov
Alex Gorbacov - avatar
+ 3
i think when reading numbers from left to right they are better read as strings. https://code.sololearn.com/cJaq8259wm4c/?ref=app
31st Aug 2017, 1:16 PM
Rabee Abbas
Rabee Abbas - avatar
20th Sep 2017, 2:26 PM
Siddu Kori
Siddu Kori - avatar
31st Aug 2017, 10:03 PM
Oberyin
Oberyin - avatar
+ 2
Here you go. Checks for valid input https://code.sololearn.com/c5chySwe0oC4/?ref=app
13th Sep 2017, 9:50 AM
Vari93
Vari93 - avatar
+ 1
https://code.sololearn.com/cvq0AY5jkJPE/?ref=app
31st Jul 2018, 1:46 PM
Nashat
Nashat - avatar