473,583 Members | 2,797 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Converting a List into a String

I have a List

list = ['f', 'e', 'd', 'c', 'b', 'a']

How can i convert it into a string so the output is

fedcba

i used

for a in list:
print a,

the output is

f e d c b a

How can i remove the spaces b/w each letter?
--
* Posted with NewsLeecher v3.0 Beta 7
* http://www.newsleecher.com/?usenet
Nov 5 '05 #1
3 82894
''.join['h','i']

bl**@blah.blah wrote:
I have a List

list = ['f', 'e', 'd', 'c', 'b', 'a']

How can i convert it into a string so the output is

fedcba

i used

for a in list:
print a,

the output is

f e d c b a

How can i remove the spaces b/w each letter?
--
* Posted with NewsLeecher v3.0 Beta 7
* http://www.newsleecher.com/?usenet


Nov 5 '05 #2
bl**@blah.blah wrote:
I have a List

list = ['f', 'e', 'd', 'c', 'b', 'a']

How can i convert it into a string so the output is

fedcba

i used

for a in list:
print a,

the output is

f e d c b a

How can i remove the spaces b/w each letter?


print "".join(lis t)

BTW list isnt a good name for a list, it hides the built in type.
Will McGugan
--
http://www.willmcgugan.com
"".join({'*':'@ ','^':'.'}.get( c,0) or chr(97+(ord(c)-84)%26) for c in
"jvyy*jvyyzptht na^pbz")
Nov 5 '05 #3
bl**@blah.blah wrote:
list = ['f', 'e', 'd', 'c', 'b', 'a']

How can i convert it into a string so the output is

fedcba


print ''.join(list)
Nov 5 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
2415
by: Ajay | last post by:
hi! how do i go about converting a Python object or tuple to a string. i am currently doing import cPickle as pickle str = pickle.dumps(obj) is thate efficient? is that the best way to do it? thanks
4
9096
by: blrmaani | last post by:
Here is what I want: string s1 = "This is a list of string"; list<string> s2 = s1.some_method(); Now, I should be able to traverse list s2 and get each member ( which is of type 'string' ). I know that this can be achieved using strtok. But I was wondering
3
1767
by: news1.sympatico.ca | last post by:
I have a single column list in the following format: John Smith 123 Anystreet Anytown, state zip Tel: 333-555-1212 Fax: 333-555-2121 Dave Jones 321 Main Street
2
1866
by: Richy | last post by:
Hi, I have a class that exposes the Microsoft.DirectX.Direct3D.Compare property, which allows a drop-down list of values (such as Never, Always etc) to be selected via the propertygrid. I write the string value ("Never", "Always" etc) to an XML file, and when I read back the XML file and set the property I want to be able to set it via the...
1
1910
by: Kevin S Gallagher | last post by:
I found this code (pretty sure it was from a MVP) for converting a string variable to a form object which works fine within a form. Take the code and place it into a code module and it fails on the second line in regards to Me.GetType.... any idea how to get this to work outside of a form? Dim strClass As String =...
0
1363
by: rrp83 | last post by:
Hi All Can anyone fwd me the code for converting a string to bytes similar to the GetBytes function in C# and viceversa?? Regards, RRP83
2
3995
by: CoreyWhite | last post by:
Problem: You have numbers in string format, but you need to convert them to a numeric type, such as an int or float. Solution: You can do this with the standard library functions. The functions strtol, strtod, and strtoul, defined in <cstdlib>, convert a null- terminated character string to a long int, double, or unsigned long. You can...
12
13376
by: Samir | last post by:
Hi Everyone, I am relatively new to Python so please forgive me for what seems like a basic question. Assume that I have a list, a, composed of nested lists with string representations of integers, such that a = , , , ]
6
1964
by: gsBytes | last post by:
I am working with a specialized graph class, which has a node class and an edge class. In the node class, there is a list of pointers to each edge. Code that uses the graph must be able to see what edges are contained in a node. This is handled by returning a const reference to a list of edge pointers, i.e: const list<Edge*>& Node::getEdges()...
1
1690
by: dhivya m | last post by:
In python I need to get the input from stdin and then convert the list to a string.I tried with rstrip but it is not working with list. Can anyone suggest someway to solve this.. Thank you..
0
7897
marktang
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
1
7940
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
8198
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
5379
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3824
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3850
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2336
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1438
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
1162
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.