Skip to content
TheChatArchiveThe Chat Archive
gpt-3.5-turbo-0301· OpenAIAi2 WildChat-4.8M (AI2)

how to convert bin number into int inpython

  1. User

    how to convert bin number into int inpython

  2. Assistant

    You can use the int() function and provide the base parameter as 2, which indicates that the input is in binary format, like this:

    bin_num = '1010'
    int_num = int(bin_num, 2)
    print(int_num)
    

    Output:

    10