back soft

مطالب مرتبط با «python list of tuples» در back soft | نویسنده: استخدام کار

IndexError: list index out of range. Why do I get this error in the second function but not the first function?

Vote count: 0 The function derivative computes the derivative of a polynomial; the degree of each entry needs to be reduced by one, each entry must be multiplied by the previous degree, and the term at degree[0] needs to be removed. This code lst = [1,2,3] """This list represents the polynomial 3x^2+2x+1""" """This function moves each entry one index down and removes the last entry""" def move(lst): copy = list(lst) for i in range(len(lst)): lst[i-1] = copy[i] del lst[-1] print lst move(lst) pro...

ادامه مطلب

how to copy contents of a LISTVIEW to a text file?

Vote count: -2 enter image description here how can I solve this problem? asked 4 mins agoDaulet Ilakhunov Let's block ads!...

ادامه مطلب

How can I make Python 3's Print fit the size of the command prompt?

Vote count: 1 Python 3 can easily handle printing a lot of text: text = "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Praesent vitae odio quis felis consectetur blandit. Etiam mattis vehicula ex id sodales. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Mauris fermentum semper nisi vel aliquam. Ut nec facilisis lectus. Maecenas auctor blandit condimentum. Donec finibus orci ac imperdiet congue. Pellentesque sem leo, commodo non metus ac, posuere maximus lorem. Class aptent ...

ادامه مطلب

python: filter a nested list of strings with list comprehension

Vote count: 0 I am trying to use list comprehension to filter this list: inp = [['Fire 46.0.1', 'vlc 2.2.3','opt 0.9.9.10'], ['opt 0.9.9.11', 'notepad 6.9', 'adobe. 6.9', 'vlc 2.3.3']] into: out = [['Fire 46.0.1', 'vlc 2.2.3',], ['notepad 6.9', 'adobe. 6.9', 'vlc 2.3.3']] i.e. removing all the strings that start with opt. I am trying something like that: [soft for ls in inp if soft not soft.startswith('opt')] but something is wrong with the sintax.Any help? asked 2 mins agodiegus Let's block ads...

ادامه مطلب

Python property on a list

Vote count: 0 I am new to Python and I just discovered the properties. It works just fine when I try it on a simple variable but I caot make it work on a list. When executing the code below it will call two times the getter and not the setter. I know that in my example the property has no added value but it is to simplify. class C: def __init__(self): self._x=[1,2,3] @property def x(self): print("getter") retu self._x @x.setter def x(self,value): print("setter") self._x=value c = C() c.x[1]=4 pr...

ادامه مطلب

Listing all the variables in a Python class

Vote count: 0 I've made a class, and after the program has finished ruing, I want to list all the variables I have kinda like so var1: val var2: val etc my class looks like this class character: name = 'Player1' level = 1 str = 100 con = 80 sta = 150 critchance = 0.1 critdmg = 0.5 # for battle hp = con * con thoughness = math.sqrt(sta) asked 2 mins agoPetter Petter Let's block ads!...

ادامه مطلب

What's wrong with Python datetime.now() in this piece of codes?

Vote count: 0 here is the codes: >>> from datetime import datetime >>> t=datetime.now() >>> print(t) And I got such a result: 2016-05-28 16:17:56.192505 How does the float number come? How could I solve it? Environment: Python 3.5.1 on Windows 10. asked 40 secs ago陈梓泉 Let's block ads!...

ادامه مطلب

selecting an item from listbox and using the name of the item later

Vote count: 0 I'm making a small project using Python 3.4/5 in conjunction with Tkinter. I have make a list box that shows all items in a directory. I can't seem to find a way to select an item and then save the name in a variable for later use. listnotes = Listbox(notebox, selectmode=SINGLE) listnotes.pack(side=LEFT, fill=Y, padx=10, pady=10) listnotes.insert(END, "notes") for i in glob.glob("TESTFOLDER*.txt"): i = i[12:] listnotes.insert(END, i) I have read around that using listnotes.get(ACTI...

ادامه مطلب

How to drop and add a new list of columns to a .csv file?

Vote count: 0 I am saving to a .csv file a preprocessed file with pandas to_csv() function as follows: retu df.to_csv(output_file, sep = '|') The output of the .csv file looks like this: |id|content|content2 0|id1|some content|some content 1|id1|some content|some content .... n|idn|more content|even more content As you can see from the above pandas objetct, the columns are not well formed: |id|content|content2 How can I remove the above columns and replace them for this new columns setting: id|c...

ادامه مطلب

Python3 Selenium Load Offline Files

Vote count: 0 So I have an rpi that will be used to display a webpage on a monitor, and I'm using python3 selenium to do it. I want it to be able to download the webpage offline so that if something happens to its coection, it still functions. I have downloaded the webpage, and it works if I manually load it (There is the main.html and main_files folder with the css, images, etc.) just by double clicking the main.html file. However, I think the issue is that selenium doesn't know where to find t...

ادامه مطلب

Fetch list of iOS contacts based on the organization name or the jobtitle

Vote count: 0 Is it possible to fetch a particular contact information or the list of contact informations based on organization name or the job title using both AddressBook and contacts framework ?? asked 2 mins agoMohamed yaseen Let's block ads!...

ادامه مطلب

Python for/in/if List Comprehension Becomes Very Slow With Large Number of Matches

Vote count: 0 I have the following list comprehension in my Python 2.7 code which retus the line number (index) and the line from a long list of lines: results = [[lines.index(line), line] for line in lines if search_item in line.lower()] This is lightning quick if the number of results is low: The search item is: [ 1330 ] Before string pre-processing, the time is: 0.0000 The number of lines is: 1,028,952 After string pre-processing, the time is: 0.2500 The number of results is: 249 "String pre-...

ادامه مطلب

Alphabetical sorting list of chars using lambda expression in C++

Vote count: 0 I'm new in C++, could you explain me how can I sort list of chars, for ex. list letters[] = {'a','c','b'}; in alphabetically order? Was looking for some friendly explanations but I found only sorting of integers using lambda expression. asked 1 min agoloup4 Let's block ads!...

ادامه مطلب

Efficient way of parsing through genetic mutation data in python

Vote count: 0 Simplistically the question I'm asking is in a given set of DNA sequencing reads what bases were mutated. To do this I created a data structure like this: baseDict = {'a':0, 't':0, 'g':0, 'c':0} varDict = {'a':baseDict, 't':baseDict, 'g':baseDict, 'c':baseDict} So, a given base can be either A, T, G, or C, and then can be mutated to any of the four bases. So and A could be mutated to a T. I am reading through a file containing mutations, and using a lot of if...elif statements to p...

ادامه مطلب

Changing Colors and ClickEvent of an Item inside a ListView(Xamarin Android)

Vote count: 0 I've just started programming not long ago so please bare with me. The problem I am facing is I am unable to change the color of my Items inside the Listview to Black color. My ListView's background (Which I've removed in order to see the items inside Listview) is supposed to be white background as well. Inside my activity, I added my items using the adapter.add("Item"). Therefore I am lost trying to add an click event on that Item since it's a string. Tried : 1) Changing propertie...

ادامه مطلب

How to use .split, enumerate and lists to find positions of a word in a sentence

Vote count: 0 I have been asked to find the position(s) of an input word from an input sentence and I am having trouble figuring out how to use enumerate, .split and lists together. This is what I have so far: sntc=str(input("Please input a sentence with no punctuation.")) wrd=str(input("Please input a word from that sentence.")) words=sntc.split list(enumerate(sntc)) for x in y in enumerate: if x==(wrd): print ("The chosen word is in postion(s):",x+1) asked 38 secs agoBig Man Let's block ads!...

ادامه مطلب

Out Of Range Exception 2D Array To List Of Type Int

Vote count: 0 Why do I get an Out of Range Exception here? My Code -the method takes int[][] numbers as a Parameter- : List myList = new List(); for (int i = 0; i < numbers.GetUpperBound(0); i++) { for (int z = 0; z < numbers.GetUpperBound(1); z++) { myList.Add(intervals[i][z]); } } I tried to Google it, but I don't have any glue. asked 3 mins agoMatthias Herrma Let's block ads!...

ادامه مطلب

How to bind the multiple selected items of list box in xaml

Vote count: 0 I have Flags Enum value which I have bound into the item source of listbox.I have used SelectionMode as Multiple.I want assign all the selected items of the listbox to flag Enum property.How can I bind the selected items? asked 2 mins agoMS.Dev Let's block ads!...

ادامه مطلب

How to write wav sound file from a list of samples?

Vote count: 0 I've got a source code on the inteet which do extract the sample values from a WAV file to a text file, like this: 1.17667 1.23074 3.07474 -0.00396729 -0.00393677 -0.00558472 -0.0159912 -0.0299072 -0.128143 -0.0204773 -0.206482 -0.252014 -0.0100098 -0.0585938 -0.317963 -0.253143 -0.302917 -0.0115967... .. How can I use it the write back, and create a wav file ? here is the code for extracting the samples value : http://pastebin.com/K375dbdj Thank you ! asked 2 mins agoHung Nguyen L...

ادامه مطلب

IndexError: list index out of range, but error is inconsistent?

Vote count: 0 I am in a intro to GIS programming class and doing a hangman game for my final project. I am very much an amateur so this might be an easy fix that I am not understanding...Here is my code: import random, sys class Hangman: def init(self,word): self.word = word self.incorrect_letters = [] self.letters_guessed = [] def hangman_loss(self): retu self.hangman_win() or (len(self.incorrect_letters) == 7) def hangman_win(self): if '_' not in self.unknown_word(): retu True retu False def g...

ادامه مطلب