Converting Hex to RGB value in Python

前端 未结 10 1084
一生所求
一生所求 2020-12-04 21:19

Working off Jeremy\'s response here: Converting hex color to RGB and vice-versa I was able to get a python program to convert preset colour hex codes (example #B4FBB8), howe

10条回答
  •  抹茶落季
    2020-12-04 21:44

    There are two small errors here!

    hex == input("")
    

    Should be:

    user_hex = input("")
    

    You want to assign the output of input() to hex, not check for comparison. Also, as mentioned in comments (@koukouviou) don't override hex, instead call it something like user_hex.

    Also:

    print(hex_to_rgb(hex()))
    

    Should be:

    print(hex_to_rgb(user_hex))
    

    You want to use the value of hex, not the type's callable method (__call__).

提交回复
热议问题