join a text with a list

222
5
Jump to solution
09-19-2022 12:53 AM
danielROUFFART1
New Contributor II

try to join a text (an adress) with a list to have at final my list with the adress in fisrt like: paris street 1 paris street 2 etc so i try to do that with this script, but it' dont work .

Can you help me?

targetPattern=r"C:\Users\**\AppData\Roaming\Esri\ArcGISPro\Favorites"
target = glob.glob(targetPattern)
print (target)
joiend = [target,Rezo]

for ready in joiend:
# JOIN TARGET
ready = (''.join([''.join(target),r'\Rezo_h@geom06.sde\rezo_h.geom04.REGIE_EAU_POTABLE']))

print (ready)

arcpy.env.workspace = ready
#list adress

fcs = arcpy.ListFeatureClasses("rezo_h.geom04.AEP*")

print (fcs)

jointure = List.insert(ready, fcs)

for ready2 in jointure:
# JOIN TARGET
ready2 = fcs.join(ready)

print ("jointure")
print (ready2)

 

Tags (3)
0 Kudos
1 Solution

Accepted Solutions
DanPatterson
MVP Esteemed Contributor

The resultant list would have to become a text list

x = [1, 2, 3]

y = ["t" + str(i) for i in x]

y
['t1', 't2', 't3']

... sort of retired...

View solution in original post

5 Replies
JohannesLindner
MVP Regular Contributor

To add an element to the end of a list, use list.append(element)

To add an element to the start of a list use list.insert(0, element)

To add all elements of a list to another list, use list.extend(other_list)

 

x = [1, 2, 3]

x.append("a")
print(x)
# [1, 2, 3, 'a']

x.insert(0, "b")
print(x)
# ['b', 1, 2, 3, 'a']

x.extend(["x", "y", "z"])
print(x)
# ['b', 1, 2, 3, 'a', 'x', 'y', 'z']

Have a great day!
Johannes
0 Kudos
danielROUFFART1
New Contributor II

Thanks for your answer but i want to insert a text before every element of my list to have at final a text like:

x= [1, 2, 3]

y = t

the result be

t1, t2, t3

 

 

0 Kudos
JohannesLindner
MVP Regular Contributor

Ah, OK.

 

x = [1, 2, 3]
y = "t"
for i, k in enumerate(x):
    x[i] = y + str(k)
print(x)
# ['t1', 't2', 't3']

 


Have a great day!
Johannes
0 Kudos
DanPatterson
MVP Esteemed Contributor

The resultant list would have to become a text list

x = [1, 2, 3]

y = ["t" + str(i) for i in x]

y
['t1', 't2', 't3']

... sort of retired...
danielROUFFART1
New Contributor II

Thanks for the help!

0 Kudos