Python lists

Hello Experts,

I am having a bit of home work difficulty. basically I am supposed to create a list of numbers, sort that list, and then display the least of the numbers, and the greatest of the numbers. I have the basic code written inputs and the like but it seems I can not make the data that is input into the list  integers nor can i make the list a varying length:

number = [""] * 10

Open in new window



if i remove the * 10 the list will only except two entries and then crash.

further is i leave in some multiple number * 10 or * whatever i cannot get display the max value or min value. I thought it was something like.

print("max value", max(number))

Open in new window


anyway i am stumped and would greatly appreciate your help.

Thanks,
Zajac lab-6.py
b_zajacAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

käµfm³d 👽Commented:
You're initializing your list with strings (the quotes you are using). If you do not enter in 10 items, then you will have 10 - n, where n is how many items you did enter, number of strings in your list. Python cannot compare numbers to string, so you get an error. What if you initialize your list with integers instead?

e.g.

number = [0] * 10

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
b_zajacAuthor Commented:
Thank you very much for setting me straight on data types in lists. I new it had to be something simple that i was over looking . I there a way to make a list an open ended variable? by that i mean not enter a multiplier. I no i can make it ridiculously long by multiplying by ten thousand for example. But i guess it would be nice for it to be infinite if it's possible.
0
b_zajacAuthor Commented:
Thank you for the help when i took notes in class i did not distinguish between str and int in lists and so i got confused.
0
käµfm³d 👽Commented:
A list is defined to be "open ended". You can append items to the list by calling the append method.
0
b_zajacAuthor Commented:
cool thank you
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Python

From novice to tech pro — start learning today.