0
How to change the string Into a number
6 Antworten
+ 9
Use int function
string = '123'
print(int(string))
read the description again
you have to take inputs and split it to convert in list
then you have to compare each value of the list with given conditions like
water cost is 4 so
for x in list:
if x == 'water':
cost = cost + 4
elif x == 'pizza'
cost = cost + 6
after getting final cost do calculation as per given conditions to get final value.
+ 4
Example like this:-
n = int(input("enter number"))
So, if we input anything from the user by default it takes input into string so if you want to convert into integers data type then you can put int before the input.
+ 4
friend.... thats what chatGPT is good for. Give it a try! It will be your companion in future.
+ 2
Python can know numbers without any thing but to make sure you can add int () to you code
0
Turn the ‘123’ into a “123”