0

Help needed with code

this is an ip validator program, it checks whether an entered ip address is valid or not. my code works but the problem is it only gives an affirmitive reply for: 100.100.100.200 100.200.100.200 and some others( i cant list them all) but if i enter 192.168.2.100 it says its not ip address.....plzz can anyone tell me where the bug is. https://code.sololearn.com/ciW1nIOOJvSk/?ref=app

10th Jun 2018, 5:30 PM
ghali lawal
ghali lawal - avatar
5 Respuestas
+ 2
You can't enter number range for regex. You will need to make one to match the 4 address numbers and then check them yourself. remove [0-255 and ] at the end and go from there, the rest if it looks valid, but I don't know Python.
10th Jun 2018, 6:17 PM
BlazingMagpie
BlazingMagpie - avatar
+ 2
Use this to check your regex: https://regexr.com
10th Jun 2018, 7:03 PM
BlazingMagpie
BlazingMagpie - avatar
0
add these lines to your code so you can see what is going on. it will help lead you to your problem print(mo1) print([i <= str(255) for i in mo1])
10th Jun 2018, 5:59 PM
LordHill
LordHill - avatar
0
BlazingMagpie its not meant to be a range, its meant to be a character class. did i mess it up?
10th Jun 2018, 6:57 PM
ghali lawal
ghali lawal - avatar
0
BlazingMagpie thnx, it was a wrong regex, confirmed it using regexr.com
10th Jun 2018, 7:33 PM
ghali lawal
ghali lawal - avatar