How to comma separate an array of integers in python? [closed]

2024/7/6 21:58:13

I have a list of integers, i want to convert them into comma separated integers, how can i actually achieve that

The result should have comma separated integers, not comma separated string example

def evaluate(self, list_of_integers):print(list_of_integers) # [220.0, 112.9] # i want to achieve something like belowprint(comma_separated_integers) # 220.0, 112.9
Answer

You can convert them to strings and then use str.join:

integers = [106, 386, 53]', '.join(map(str, integers))

Output:

'106, 386, 53'
https://en.xdnf.cn/q/120363.html

Related Q&A

Python 2.7.5 - Where is it installed on Windows Vista? [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.This question does not appear to be about a specific programming problem, a software algorithm, or s…

Python list of lists specific path combinations or permutations

I have a list of lists and am looking for something similar to combinations or permutations, but there are conditions that may result in good "Path" or "Dead_End". If "Dead_En…

Python packages.import sys vs from sys import argv

Im trying to use argv into my python script. For this im using following code:from sys import argv script, file_name = argv print(file_name)python3 e.py e.txt This code works fine.But when I use:import…

How to reorganize a list of tuples?

Say I had a list of tuples:[(98, studentA), (97, studentB), (98, studentC), (95,studentD)]And I wanted to organize it so that the students are grouped together by the first number in the tuple, what wo…

How to loop through json data with multiple objects

My json file data.json looks like this [ {"host" : "192.168.0.25", "username":"server2", "path":"/home/server/.ssh/01_id"}, {"host"…

python django only the first statement statement can be accessed

i can acccess only the first statement in my name appjavascript:<script type="text/javascript">function searched(){{% for names in name %}nameSearched = document.getElementById(name).va…

syntax error return outside function in python

I am trying to count the word fizz using python. However it is giving me an error.def fizz_count(x):count =0 for item in x :if item== "fizz":count=count+1 return countitem= ["fizz",…

How to replace values in multidimensional array?

I am trying to get a multidimensional array working, where the user string is filled in the cell. I have been searching for ways to update user values in the multidimensional array def createMultiArr…

How to deploy a python docker image to AWS Lambda?

I am trying to figure out how to deploy a flask application that I have received with a Dockerfile to AWS Lambda.In local, all I have to do to start the app is to enter docker-compose up. Thats work gr…

How to isolate titles from these image URLs?

I have a list of image urls contained in images. I am trying to isolate the title from these image urls so that I can display, on the html, the image (using the whole url) and the corresponding title. …