New to Tkinter

+1 Jerry Hunt · November 16, 2014
How can I get a list of numbers, in an entry box?

I am trying to write a program that asks the user to enter a series of numbers like: 4,8,12,10,8,4,20. Then, I want to do something with each of the numbers. But when I enter the numbers, I get a string length of 16 - the number of single characters and the commas.

Post a Reply

Replies

Oldest  Newest  Rating
0 Justin Red · November 16, 2014
I'm new to python but does this not work?


numbers = raw_input("enter a list of numbers:")
new_numbers = numbers.split(",")
for i in new_numbers:
    print i

I'm not sure about doing something with them afterwards so please forgive this answer if I'm way off.

>>> ================================ RESTART ================================
>>> 
enter a list of numbers:1,2,3
1
2
3
>>> ================================ RESTART ================================
>>> 
enter a list of numbers:1 2 3
1 2 3
>>> 
0 Jerry Hunt · November 16, 2014
Thanks!

.split(",") is what I was missing. I added it to my code and it works!
  • 1

Python

103,429 followers
About

This section is all about snakes! Just kidding.

Links
Moderators
Bucky Roberts Administrator