Python Forum

Full Version: square root of 6 input numbers
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
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
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.
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
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?