+ 2
How to check whether given value is hex or not in python?
5 Réponses
+ 11
Use search before asking questions!
https://www.sololearn.com/Discuss/1480962/?ref=app
+ 7
Dr£@M_c@tcH£r , in some cases you can not check if it is binary or decimal number:
1, 101, 11, ...
In this case you need additional information as a prefix of the binary number like: "0b10110". so 0b indicates that the number is binary, 0x is hexadecimal and 0o is octal.
+ 6
I will give you a hint: the int(string,base) function accepts a second parameter (base) which indicates the number system that you want to convert from(like 16 for hex). If the conversion is not correct, it will raize a ValueError exception.
+ 6
Dr£@M_c@tcH£r , please show us your attempt first. Please put your code in playground and link it here. Thanks!
+ 4
Issue is resolved. Thanks for the help