+ 2
Int() not working
Sample input: take1= input("a") int(take1) print(take1 == type(int)) print(take1 == type(str)) print(type(take1)) Sample output False False <class "str" > #this does not make sense to me
5 Antworten
+ 2
Dear Python learner .The solution is to do it like this:
Take = int(Take)
If you do this:
Take = int()
#it will create an empty integer = 0
+ 3
Hi again!
That's because, this is not a proper way to convert a string to an integer. You can do it like this
take2 = int(take1)
This is how type() function is used to compare a variable type.
type(take1) == int
type(take1) == str
and so on
+ 2
Best Way to Get Numbers From String:
x=input()
lst=[]
for i in x:
if i.isdigit():
lst.append(i)
else:
None
print(''.join(lst))
0
Python learner is amazing
0
Try to put
int and str in quotes