How to convert an integer to hexadecimal without the extra '0x' leading and 'L' trailing characters in Python?
hex, python
Solution
Sure, go ahead and remove them.
hex(bignum).rstrip("L").lstrip("0x") or "0"
(Went the `strip()` route so it'll still work if those extra characters happen to not be there.)
Problem
I am trying to convert big integer number to hexadecimal, but in result I get extra "0x" in the beginning and "L" at the and. Is there any way to remove them. Thanks. The number is: ``` 44199528911754184119951207843369973680110397865530452125410391627149413347233422 34022212251821456884124472887618492329254364432818044014624401131830518339656484 40715571509533543461663355144401169142245599341189968078513301836094272490476436 03241723155291875985122856369808620004482511813588136695132933174030714932470268 09981252011612514384959816764532268676171324293234703159707742021429539550603471 00313840833815860718888322205486842202237569406420900108504810 ``` In hex I get: ``` 0x2ef1c78d2b66b31edec83f695809d2f86e5d135fb08f91b865675684e27e16c2faba5fcea548f3 b1f3a4139942584d90f8b2a64f48e698c1321eee4b431d81ae049e11a5aa85ff85adc2c891db9126 1f7f2c1a4d12403688002266798ddd053c2e2670ef2e3a506e41acd8cd346a79c091183febdda3ca a852ce9ee2e126ca8ac66d3b196567ebd58d615955ed7c17fec5cca53ce1b1d84a323dc03e4fea63 461089e91b29e3834a60020437db8a76ea85ec75b4c07b3829597cfed185a70eeaL ```