Question : convert string to boolean python
Answered by : abdel
is_paid = "True"
if eval(is_paid): print("Payment made")
else: print("Payment not made")
Source : | Last Update : Mon, 06 Feb 23
Question : python string to boolean
Answered by : jerome-scott
print(str(1)) # convert number to string
print(int("1")) # convert string to int
print(float(1)) # convert int to float
print(list('hello')) # convert string to list
print(tuple('hello')) # convert string to tuple
print(list((1, 2, 3))) # convert tuple to list
print(tuple([1, 2, 3])) # convert list to tuple
print(bool(1)) # convert a number to boolean
print(bool(0)) # convert a number to boolean
print(bool("")) # convert a string to boolean
print(bool("data")) # convert string to boolean
print(bin(10)) # convert an integer to a binary string
print(hex(10)) # convert an integer to a hex string
print(oct(10)) # convert an integer to an octal string
Source : https://codefreelance.net/python_cheatsheet.html | Last Update : Tue, 30 Aug 22
Question : python string to boolean
Answered by : itchy-ibex-08gjt61f0gfp
isTrue = "True" == "True"
Source : | Last Update : Thu, 24 Feb 22