I want to change a tuple into string without joining it in python. How could I do that? [duplicate]

2024/11/8 7:55:51

For Example: I want to change t=('a', 'b', 'c') to s='a', 'b', 'c'

Answer
  t = ('a', 'b', 'c')s = 'a','b', 'c'print(s==t)# output True

if you want s = 'a,b,c' then you can do it by joining which you do not want to do. Also, it's useless to write 'a','b','c' as string, however you can do that by using commented code. Please consider writing s = a,b,c

s = ''
for i in t:s += str(',') + i          # s += str(',') + str("'") + i + str("'")
s = s[1:]
https://en.xdnf.cn/q/120638.html

Related Q&A

Convert several YAML files to CSV

I am very new to Python and have several YAML files that I need to convert into csv. These are notes, comments and emails that came from our CRM (Highrise). I ONLY need the Notes and Comments, not the …

Python split unicode characters and words

Im running a data science project and i need your help.My string is:string = 🎁Testand I expect that output:s1 = 🎁s2 = Test

How to run two Flask discord.py bots in the same repl.it project?

I am using repl.it to run two bots in the same repl and Im using imports as a I saw in other stackoverflow questions. print(This will be the page where all bots will be made.) import os import bot1 imp…

build a perfect maze recursively in python

I have this project to build a perfect maze recursively by using python. I have a MyStack class which creates a stack to track the path that I go through. And a Cell class which represent each square w…

How do I select random text on screen [closed]

Closed. This question needs debugging details. It is not currently accepting answers.Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to repro…

Conditional return with no else [duplicate]

This question already has answers here:Python Ternary Operator Without else(9 answers)Closed 10 months ago.Im try to do something like that in Python:return None if a is NoneInstead of having:if a is N…

Finding the position of an item in another list from a number in a different list

Developing on my previous question Im wondering whether there is a way to have an element in a list and find that position in another list and return what is in the position as a variable. for example:…

Why am I getting array instead of vector size? [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.Want to improve this question? Add details and clarify the problem by editing this post.Closed 3 years ago.Improve…

Sending Email attachment (.txt file) using Python 2.7 (smtplib) [duplicate]

This question already has answers here:How to send email attachments?(21 answers)Closed 9 years ago.So Im trying to send a .txt file as an attachment and I cant find the right code to work. Here is my…

Python selenium drop down menu click

i want to select option from a drop down menu, for this i use that :br.find_element_by_xpath("//*[@id=adyen-encrypted-form]/fieldset/div[3]/div[2]/div/div/div/div/div[2]/div/ul/li[5]/span").c…