Hello all. I am new to programming, taking my first class in college. Im enjoying it a lot so far, and much of the info on daniweb has been a huge help. Due to some unforeseen circumstances, I had to miss class and am now having some troubles with a program.

We have to create a program that asks the user for a list of numbers separated by commas(if they are floats they are to be rounded). The program is then supposed to print out stars(*) based on each number in the list. Im having trouble getting the user input, converting it to an integer, and putting it into a list.

I have tried

numList=list(input("Enter a list of numbers: "))

to actually create a list with the input but Im not sure how to convert it into an integer afterward (keep getting an error) and separate everything properly.

Also gave this a shot, but same problems.

numList=[]
numbs=input("Enter a list of numbers separated by commas: ")
numList.append(numbs)

Any help would be appreciated. And I am using python 3.1.3. Thanks!

Edit: I should also probably mention that I can't even use anything to advanced as this is a beginner class. Havent even gotten into functions yet.

Ive been working on it and so far I have come up with this

numList=[]
numbs=input("Enter a list of numbers separated by commas: ").split(",")
numList.append(numbs)
numList2=[float(i) for i in numList]

but I keep getting this error

Traceback (most recent call last):
  File "C:\Users\AAA\Documents\Python Prog\histo.py", line 4, in <module>
    numList2=[float(i) for i in numList]
  File "C:\Users\AAA\Documents\Python Prog\histo.py", line 4, in <listcomp>
    numList2=[float(i) for i in numList]
TypeError: float() argument must be a string or a number

Edit: it seems that doing this

numList=[]
numbs=input("Enter a list of numbers separated by commas: ").split(",")
numbs2=[float(i) for i in numbs]
numList.append(numbs2)

gave me a list with floats. Thought that using a for loop to iterate through the floats in the list would work to print out the stars, but so far Im just getting a lot of errors.

Figured it out. May not be the simplest way but its done.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.