[Solved] shift each letter of words by value

You need to do the assignment yourself (or there is no point in learning to program) and if you don’t understand the question, you should ask your teacher for clarification. That said, shifting is quite simple in principle. You can do it by hand. If you have a letter, say A, shifting it by 1 … Read more

[Solved] How to create a file with filename as key of dictionary

You may open k and not ‘k’ imports = [“import json”, “import defaultdict”] d = {‘1’: ‘print (“This is test file”)’, ‘2’: ‘print (“This is test file”)’} for k, v in d.items(): with open(k + “.py”, ‘w’) as fr: for imp in imports: fr.write(imp + “\n”) fr.write(v) solved How to create a file with filename … Read more

[Solved] How to reduce any number not equal to 0 to 1 and any number equal to 0 kept at 0 in Python? [closed]

The first behaviour you list is mathematically called the signum operation. If you are allowed to use numpy, i’d simply do: import numpy sign = numpy.sign(x) With regard to your 2nd question, that’s quite easy. Simply use: int(bool(x)) Edit: With some tinkering i found a solution for your first question, too: negsign = int(int(num) >> … Read more

[Solved] How does formatting a Python date object with str.format() work?

The date class defines the __format__() magic method, which is called by str.format() to produce a “formatted” string representation of an object. To quote the documentation for date.__format__(): Same as date.strftime(). This makes it possible to specify a format string for a date object in formatted string literals and when using str.format(). For a complete … Read more

[Solved] Schrodingers JSON – when working with a json doc it is erroring as both a list and a dict

As @Hitobat mentioned in commend – you have list with dictionary inside so you have to use [0] to get this dictionary. Or you have to use for-loop if you have more elements on list data = [{‘_id’: ‘5f563c1bf8eaa9d98eca231f’, ‘allEnabledDs’: None, ‘allEnabledIdSor’: None, ‘correlationFilterEntitySource’: True, ‘created_at’: ‘2020-09-07T13:56:43.469Z’, ‘dsConnectionList’: None, ‘folderToLabelMapping’: None, ‘idConnectionList’: None, ‘identityResolutionScan’: False, … Read more

[Solved] Where to get the positions of the last item in the Listbox (python and tkinter)?

You can get the numerical index of the last item with the documented index command, passing in the special string “end”: last_index = the_listbox.index(“end”) To get the value of the last item you can use “end” in the get method as well: last_value = the_listbox.get(“end”) To make sure that the last item in the listbox … Read more

[Solved] How do I extract the characters in between the specific set of characters in a string python(regex)? [closed]

import re txt = “””div><div class=”ShLswe”><a class=”_2WFi0x” href=”https://stackoverflow.com/order_details?order_id=OD40818094004&amp;item_id=OD408180940040000&amp;unit_id=OD408180940040000000″><div class=”row”><div class=”col-6-12″><div class=”row”><div class=”col-3-12″><div class=”J2h1WZ”><div class=”_3BTv9X” style=”height: 75px; width: 75px;”><img class=”_1Nyybr _30XEf0″ alt=”” src=”https://rukminim1.flixcart.com/image/75/75/usb-adaptor/s/9/8/tp-link-150-mbps-wireless-n-original-imad8rruefj6rf3y.jpeg”></div></div></div><div class=”col-8-12″><div class=”_3D-3p2″><span class=”row _13y4_y _1iu0PI”>TP-LINK 150 Mbps TL-WN721N Wireless N</span><div class=”row _3i00zY”><span class=”_3i00zY _2n1WrW”>Seller: </span><span class=”_2dTbPB”>WS Retail</span></div></div></div></div></div><div class=”col-2-12 JL36Xz”>₹512</div><div class=”col-4-12 _3Yi3bU”><div><div class=”_30ud5x _3ELbo9″></div><span class=”_7BRRQk”>Delivered on Aug 20, 2014</span><div class=”_2t-3dH”>Your item has been delivered</div></div><div … Read more