Python Forum
square root of 6 input numbers
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
square root of 6 input numbers
#1
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
Reply
#2
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.
Reply
#3
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
Reply
#4
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?
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Im at square one even with trying to install python origen 1 352 Jan-12-2024, 05:39 AM
Last Post: ndc85430
  ValueError: Found input variables with inconsistent numbers of samples saoko 0 2,475 Jun-16-2022, 06:59 PM
Last Post: saoko
  Found input variables with inconsistent numbers of samples: [1000, 200] jenya56 2 2,893 Sep-15-2021, 12:48 PM
Last Post: jenya56
  square root of 5 input numbers mrityunjoy 1 2,026 Jun-10-2020, 11:08 AM
Last Post: perfringo
  How to simplify square finding program? meknowsnothing 3 2,910 Jun-11-2019, 08:20 PM
Last Post: meknowsnothing
  Print Numbers starting at 1 vertically with separator for output numbers Pleiades 3 3,735 May-09-2019, 12:19 PM
Last Post: Pleiades
  unable to pass a input after changing the user from root to non root using python avinash 3 3,189 Apr-08-2019, 10:05 AM
Last Post: avinash
  converting arguments or input numbers Skaperen 8 4,479 Aug-21-2018, 12:17 AM
Last Post: Skaperen
  cropping a picture (always square) Leon 1 2,142 Aug-13-2018, 10:04 AM
Last Post: Leon
  Error when trying to square a number pistacheoowalnuttanker 5 3,818 Jul-20-2018, 02:23 AM
Last Post: pistacheoowalnuttanker

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020