473,379 Members | 1,201 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,379 software developers and data experts.

Fwd: string concatenate

On Oct 1, 2008, at 12:41 PM, sandric ionut wrote:
Hi:

I have the following situation:
nameAll = []
for i in range(1,10,1):
n = "name" + str([i])
nameAll += n
print nameAll

I get:

['n', 'a', 'm', 'e', '[', '1', ']', 'n', 'a', 'm', 'e', '[', '2',
']', 'n', 'a', 'm', 'e', '[', '3', ']', 'n', 'a', 'm', 'e', '[',
'4', ']', 'n', 'a', 'm', 'e', '[', '5', ']', 'n', 'a', 'm', 'e',
'[', '6', ']', 'n', 'a', 'm', 'e', '[', '7', ']', 'n', 'a', 'm',
'e', '[', '8', ']', 'n', 'a', 'm', 'e', '[', '9', ']']

but I would like to have it as:

name1 name2 name3 ...name10

How can I do it?

Thank you,

Ionut
nameAll = []
for i in xrange(1,10,1):
n = "name" + str(i)
nameAll.append(n)
print nameAll
['name1', 'name2', 'name3', 'name4', 'name5', 'name6', 'name7',
'name8', 'name9']

list.append() is the right tool for adding new elements to a list.

Cheers
Tommy

Oct 1 '08 #1
0 648

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

Similar topics

8
by: Ralph Freshour | last post by:
Is it possible to inhibit the browser Back/Fwd buttons via PHP? Thanks...
5
by: Jonas Galvez | last post by:
Is it true that joining the string elements of a list is faster than concatenating them via the '+' operator? "".join() vs 'a'+'b'+'c' If so, can anyone explain why?
35
by: michael.casey | last post by:
The purpose of this post is to obtain the communities opinion of the usefulness, efficiency, and most importantly the correctness of this small piece of code. I thank everyone in advance for your...
3
by: Tom | last post by:
Hi I want to retrieve database data and concatenate them to a string. Here is my code .ToString()); //runtime error her } while (dr.NextResult()) string array =...
5
by: Generic Usenet Account | last post by:
I have been to recreate a problem that I am having with strings with the trivial code snippet given below. In the trivial code example, I am reading five lines from a data file, each line having...
6
by: Registered User | last post by:
Hi experts, I'm trying to write a program to solve the following exercise: Accept three strings from the user. Find the first occurrence of the first string in the third string. If it is present...
0
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
7
by: largedimples | last post by:
The assignment was as follows: A character string can be implemented as a linked list of characters. Implement a C++ ADT called Newstring that uses linked lists to implement the following string...
1
by: jake77.lucas | last post by:
I'm using 2005.Net C++ compiler. I have a base class in namespace A (call it Class1). I derive another class from it, (call it Class2) defined in namespace B. This derived class contains as a...
13
by: sinbad | last post by:
hi, how to concatenate a "hash defined" constant value to another "hash defined" constant string. For example #define ABC 100 #define MYSTR "The value of ABC is" Now i need a string that...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
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...
0
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
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
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 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.