[Solved] How can I write a python code where it extracts full names from a list of names

One way: storeFullNames = [] storeFullNames.append(‘Jane Doe’) storeFullNames.append(‘Ray Charles’) print(storeFullNames) Second way: storeListNames = [] for name in names: if len(name.split(‘ ‘)) > 1: storeListNames.append(name) print(storeListNames) both ways return a list with full names only… solved How can I write a python code where it extracts full names from a list of names

[Solved] How to extract URL from HTML anchor element using Python3? [closed]

You can use built-in xml.etree.ElementTree instead: >>> import xml.etree.ElementTree as ET >>> url=”<a rel=”nofollow” href=”https://stackoverflow.com/example/hello/get/9f676bac2bb3.zip”>XYZ</a>” >>> ET.fromstring(url).attrib.get(‘href’) “https://stackoverflow.com/example/hello/get/9f676bac2bb3.zip” This works on this particular example, but xml.etree.ElementTree is not an HTML parser. Consider using BeautifulSoup: >>> from bs4 import BeautifulSoup >>> BeautifulSoup(url).a.get(‘href’) “https://stackoverflow.com/example/hello/get/9f676bac2bb3.zip” Or, lxml.html: >>> import lxml.html >>> lxml.html.fromstring(url).attrib.get(‘href’) “https://stackoverflow.com/example/hello/get/9f676bac2bb3.zip” Personally, I prefer BeautifulSoup – … Read more

[Solved] Disable button in Tkinter (Python)

You need to unbind the event. state=”disabled”/state=DISABLED makes button disabled but it doesn’t unbind the event. You need to unbind the corresponding events to achieve this goal. If you want to enable the button again then you need to bind the event again. Like: from Tkinter import * def printSomething(event): print(“Print”) #Start GUI gui = … Read more

[Solved] i want my code to output something like “example = .-.-.-.-” but rather it outputs “example = .- = .- = .- = .-” [closed]

cache += ‘ = ‘ was in the loop, causing the error. def morse_encrypter (placeholder): cache = d cache += ‘ = ‘ for letter in placeholder: cache += cheat_sheet [letter] return cache 3 solved i want my code to output something like “example = .-.-.-.-” but rather it outputs “example = .- = .- … Read more

[Solved] How to fetch date and time

You can use this function to check if an error exists: def checkError(Str): if ‘ERROR’ in Str: openBracket = Str.find(‘(‘)+1 closedBracket = Str.find(‘)’) status = “”.join(Str[openBracket:closedBracket]) error = “\n”.join([‘YES’,”, “.join(Str.split(‘\n\n’)[2].split(‘, ‘)[1:]),status]) return error else: return ‘No errors found.’ error = checkError(Str) print(error) Output: YES 22:17:31 Wed Feb 11, 2015 software ERROR 0 solved How to … Read more

[Solved] How to use global variables in Python?

The declaration of your globals is wrong. You declare your globals as a description of how they should be calculated. That will just not work. The global keyword in python is used to bring a variable in the local scope. Then you can alter it. Like this: def updateGlobals(): global global_variable global_variable = “new value” … Read more

[Solved] How to design mathematical program which calculate the derivative of a function using python? [closed]

Taking a function is easy… it’s just like any other argument. def example(somefunc): somefunc() example(someFunction) example(lambda x: x ** 2) Returning one is a little trickier, but not much. You can return a lambda: def example2(): return lambda x: x + 1 Or you can build an inner function, and return that def example3(): def … Read more