Hi all
I have a list like:
>>list
[1, 2, 3]
>>list[1:]
[2, 3]
I want to get a string "2 3"
>>str(list[1:])
'[2, 3]'
How can I do that ?
thanks 5 2469
On 18 Oct 2006 00:20:50 -0700, Jia Lu <Ro*****@gmail.comwrote:
I want to get a string "2 3"
>str(list[1:])
'[2, 3]'
How can I do that ?
' '.join(str(i) for i in list[1:])
-- Theerasak
Jia Lu wrote:
Hi all
I have a list like:
>>>list
[1, 2, 3]
>>>list[1:]
[2, 3]
I want to get a string "2 3"
>>>str(list[1:])
'[2, 3]'
How can I do that ?
" ".join(str(x) for x in list)
-Travis
Jia Lu wrote:
Hi all
I have a list like:
>>>list
[1, 2, 3]
>>>list[1:]
[2, 3]
I want to get a string "2 3"
>>>str(list[1:])
'[2, 3]'
How can I do that ?
thanks
Just to be different from the other suggestions...
>>a = [1, 2, 3] str(a[1:]).strip('[]').replace(',', '')
'2 3'
By the way. It's a good idea to try not to use 'list' or other built-in names
for your own objects. Best to start with good habits so that you avoid odd hard
to find bugs later.
Cheers,
Ron
Thank you very much. I memoed all you views.
:) This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Klaus Neuner |
last post by:
Hello,
I need a function that converts a list into a set of regexes. Like so:
string_list =
print string_list2regexes(string_list)
This should return something like:
|
by: Andrew V. Romero |
last post by:
At work we have an excel file that contains the list of medications and
their corresponding strengths. I would like to save the excel file as a
text list and paste this list into a javascript...
|
by: aevans1108 |
last post by:
expanding this message to microsoft.public.dotnet.xml
Greetings
Please direct me to the right group if this is an inappropriate place
to post this question. Thanks.
I want to format a...
|
by: Steve |
last post by:
I have a very simple datatable of 1 column which I retrieve from a
database, call it 'data'.
Dim data As Data.DataTable
data = myobject.mymethod(parameter)
I want to now turn this 'data' into...
|
by: comp.lang.tcl |
last post by:
I have a TCL proc that needs to convert what might be a list into a
string to read
consider this:
]; # OUTPUTS Hello World which
is fine for PHP
]; # OUTPUT {{-Hello}}
World, which PHP...
|
by: Learner |
last post by:
Hello,
Here is the code snippet I got strucked at.
I am unable to convert the below line of code to its equavalent vb.net
code. could some one please help me with this?
static public...
|
by: comp.lang.tcl |
last post by:
My TCL proc, XML_GET_ALL_ELEMENT_ATTRS, is supposed to convert an XML
file into a TCL list as follows:
attr1 {val1} attr2 {val2} ... attrN {valN}
This is the TCL code that does this:
set...
|
by: CodeMonkey775 |
last post by:
I'm having problems passing a variable to a method which is executed and compiled using CodeDom. The situation is I have a List<CellData> with cells, each containing a formula (like Excel). I am...
|
by: pnbaocuong |
last post by:
Dear All
When I try to use convert function of MS sql server like this:
String sql = " (employee_id = '" + employee_id + "') and ((convert(VARCHAR,w_date,103) = '" + w_date + "'))";
...
|
by: myotheraccount |
last post by:
Hello,
Is there a way to convert a DataRow to a StringArray, without looping
through all of the items of the DataRow?
Basically, I'm trying to get the results of a query and put them into
a...
|
by: taylorcarr |
last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
| |