Python: Convert true to 1 and false to 0
Boolean to Integer Converter
Write a Python program to convert true to 1 and false to 0.
Sample Solution:
Python Code:
Sample Output:
1 0
Flowchart:

For more Practice: Solve these Related Problems:
- Write a Python program to convert a boolean list into a list of 1s and 0s.
- Write a Python function to convert True/False strings into integers.
- Write a Python program to count the number of True values in a boolean list.
- Write a Python function to toggle True to False and False to True, then convert to integers.
Go to:
Previous: Write a Python program to extract single key-value pair of a dictionary in variables.
Next: Write a Python program to valid a IP address.
Python Code Editor:
What is the difficulty level of this exercise?
Based on 68 votes, average difficulty level of this exercise is Hard
.
Test your Programming skills with w3resource's quiz.