Answer the question
In order to leave comments, you need to log in
Python invalid syntax error when writing empty string?
import math
r=input('Enter the radius of the ball: ')
pi=input('Enter the number Pi: ')
r=float(r)
pi=float(pi)
while r=" ": #Writes that there is an error in the equal sign, tell me what to do?
#Bq start while
v=4/3*pi*pow(r,3)
print('The volume of the ball is%2f'%v)
#Bq end while
main()
Answer the question
In order to leave comments, you need to log in
You cannot make an assignment in a loop condition.
You need to write == if you want to compare.
>>while r=" "
If this was written to check if the string is empty, then I recommend replacing it with:
>>while not r:
While r is undefined, we will try to calculate the volume, where is this r used? Maybe I don't understand something, but after correcting while r=" " to while not r, it still won't work for undefined r. What for here in general while?
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question