Questions tagged as 'tuple'

2
answers

Is Tuple the same thing as creating an object?

I've used Tuple a few times today came the doubt, this: public class User{ public String Name {get; set;} public String LastName {get; set;} } new User(){ Name = "Leonardo", LastName = "Bonetti" } Is it the same as...
asked by 13.08.2018 / 17:05
1
answer

Transform list of strings into list of tuples

I have this: l=['Car 8', 'Bike 5', 'Train 10'] And I would like to have something like this: [('Car','8'), ('Bike','5'), ('Train','10')] How could you make a list of strings into something like a list of strings tuples?     
asked by 05.12.2017 / 01:27
1
answer

Is there a performance difference between Tuple and List?

In Python, I know there is a difference between a Tuple and a List . The Tuple is immutable, and the List , changeable. You may already have this question here: What is the main difference between a Tuple and a List...
asked by 16.11.2016 / 16:41
1
answer

Read Data from a .csv file and pass line values to Tuple

The data in the cities.csv file is organized as follows: Lisbon, Madrid, 600 Madrid, Paris, 650 import csv with open('cidades.csv', 'r') as f: # Somente r para leitura do arquivo list1 = [tuple(line.values()) for line in csv.DictRe...
asked by 09.11.2017 / 02:53
1
answer

Python - Type function in tuples

Hello, I'm trying to make a program in Python, which gets a positive integer. This program should check whether it is integer ( with type ) and whether it is positive . You should return a tuple of integers containing the digits of that nu...
asked by 12.05.2018 / 17:53
1
answer

Tuples: index out of range - recursion

I'm having a problem with index out of range in my tuple. The purpose of the code is to create a recursive function that finds a substring within a tuple with elements of any type. Could someone help me with this error? The problem i...
asked by 06.09.2017 / 02:59
1
answer

Sort tuple by key in Python 3

I have a lista_tupla = [(1, [1, 2, 3, 4]), (2, [5, 6, 7]), (3, [7, 8, 9]), (3, [10, 11, 12]), (4, [13, 14, 15])] where the first index of each tuple is a key and the second index is a list as above. I would like to know: how do I sort...
asked by 17.07.2016 / 18:27
1
answer

Difference between tuple and set

I'm working with python and I was wondering what would be the difference between a set () () and a tuple (). I know that both are delimited with '()'. But I tried to assign a set attribute to a tuple, that is: THIS IS MY SET: (OR WHAT I TH...
asked by 19.11.2015 / 20:57
1
answer

How to remove a tuple from within a list

Good afternoon, I have a problem with a job that is as follows: I have a function that needs lists to organize multiple elements according to predefined characteristics. My question is how do you pull a tuple from within a list as shown in the e...
asked by 08.12.2018 / 15:50
1
answer

How to test if all elements are tuples of 2 elements [duplicate]

I am solving an exercise that first of all I have to test if the argument received is a tuple. If yes, I have to test if all its elements are tuples of 2 elements, where the 1st is a string, and the 2nd is an integer. I know that to test if...
asked by 09.11.2018 / 03:00