I thought I was copying word for word from a previous question/answer, but, I don't get what I wanted.
I was trying to answer a question from an online list of python questions for beginners. I wrote the following in a file called q.py
and then gave the executed it with python3 q.py
in my shell.
The file q.py
looks like:
from math import sqrt
C=50
H=30
inp = input('input values: ')
vals = inp.split(',')
print(vals)
for x in vals:
D=int(x)
print(int(sqrt(2*C*D/H)),sep=',',end='')
print()
I input 100,150,180
as the question suggested, the required answer is:
18,22,24
but the answer I get is:
182224
When I omit the "end"
argument to print
, I get 18
, 22
, and 24
separated by newlines.