Python Forum
square root of 6 input numbers - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: General Coding Help (https://python-forum.io/forum-8.html)
+--- Thread: square root of 6 input numbers (/thread-27438.html)



square root of 6 input numbers - mrityunjoy - Jun-07-2020

Hi,

I want to find sqrt of 6 input numbers and append the result in lst (an empty array), Not able to pass multiple input in a function

from math import sqrt
def lists():
    x = input("Enter six value: ").split()
    
    lst = []  
    for i in x:
        math.sqrt(i)
    lst = lst.append(i)
    print(lst)
    print(type(ele))   
    return lst
list()
Please your support


RE: square root of 6 input numbers - ndc85430 - Jun-07-2020

Note that input returns a string, so you need to convert the values in x to numbers (with the int or float functions, for example).

Also, please use "[python]" tags when posting code, because it adds syntax highlighting, line numbering and keeps the indentation.


RE: square root of 6 input numbers - mrityunjoy - Jun-07-2020

from math import sqrt
def lists():
x = int(input("Enter six value: ").split())

lst = []
for i in x:
math.sqrt(i)
lst = lst.append(i)
print(lst)
print(type(i))
return lst
list()
Please help me to fix the code


RE: square root of 6 input numbers - ndc85430 - Jun-07-2020

There's no indentation. If it's not like that in your editor, then come on: you're probably getting some exceptions aren't you? What are they and what you do you think they mean?