O
O
OMGhostO_02015-10-08 21:02:31
Python
OMGhostO_0, 2015-10-08 21:02:31

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

4 answer(s)
O
OnYourLips, 2015-10-08
@OnYourLips

You cannot make an assignment in a loop condition.
You need to write == if you want to compare.

V
Vladimir Martyanov, 2015-10-08
@vilgeforce

Error messages must be given in full...

D
Dmitry, 2015-10-08
@EvilsInterrupt

>>while r=" "
If this was written to check if the string is empty, then I recommend replacing it with:
>>while not r:

A
Alexey Serebryakov, 2015-10-09
@VoltSilver

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 question

Ask a Question

731 491 924 answers to any question