How to force a single number to be a tuple
Roy Smith
roy at panix.com
Wed Aug 4 12:27:12 EDT 2004
In article <mailman.1138.1091636758.5135.python-list at python.org>,
"Jinming Xu" <cybermanxu at hotmail.com> wrote:
> Hi Folks,
>
> I have a number sequence, which is put into a tuple like this:
>
> y=2, 3.0, 4.5
>
> I can manipulate the sequence as a tuple when it has more than 1 number. But
> when the sequence has only 1 number, like
>
> y=2
>
> I have trouble to manipulate it as a tuple. I guess there must be a way to
> forece a single number to be a tuple. Could anyone please tell me that?
You're going to get a zillion responses to this one.
The syntax is a bit funky:
y = (2,)
More information about the Python-list
mailing list