[Solved] How to update values in nested dictionary [closed]

There are some deeper flaws with your dictionary structure, such as values included without a key, and I would recommend reading a good tutorial on dictionary structure and reference: https://realpython.com/python-dicts/ For your base question, though, you would treat the value in the secondary dictionary as a value of the dictionary. Given the following dictionary (edited … Read more

[Solved] merging 2 lists as a key value pair in python

You can make l3 a dictionary, which stores key-value pairs: >>> l3 = dict( zip(l1.split(‘,’), l2.split(‘,’)) ) >>> l3 {‘brand’: ‘car’, ‘color’: ‘red’, ‘model’: ‘2009’, ‘value’: ‘100000’} But if you just need a string, you can use join: >>> l3 = ‘,’.join([ ‘%s:%s’ % (k, v) for k, v in zip(l1.split(‘,’), l2.split(‘,’)) ]) >>> l3 … Read more

[Solved] Why this is showing a syntax error?

Two things, just at a glance. As Rakesh’s answer states, platform00.upper() = input(“etc”) is not valid syntax, and should replaced with platform00 = input(“etc”).upper(). The way you have it, you’re attempting to set a value to a non-variable, specifically the return value of a function. For a second thing, you have a curly brace in … Read more

[Solved] SQL and calling a function

No code after login.go() will be executed until the GUI is closed – calling login.go() starts the GUI’s event loop, this is where tktiner is checking for events. I would define the function at the top of your code, and then put the line that calls GetNews(usr) on the line before login.go() If the GetNews(usr) … Read more

[Solved] How to concatenate a string in python?

Just pass empty string to end parameter in print function after strippping off the newline character. print (line, end = “”) print by default print the content in a new line for each iteration but by passing empty string to the end parameter, this default behaviour won’t work. If you failed to remove the newline … Read more

[Solved] Python – ValueError: invalid literal for int() with base 10: ‘hello’

The following solution worked. Instead of using int(x) , we need to use len(x.encode(‘utf-8′)) so the final code is updated as import io with io.open(r’C:\Python\Data\somefile.txt’,’r+’) as fp: bytecolumn = (line.rsplit(None,1)[1] for line in fp) bytes = ( len(x.encode(‘utf-8’)) for x in bytecolumn if x != ‘-‘) print(‘Total’, sum(bytes)) solved Python – ValueError: invalid literal for … Read more

[Solved] Checking for elements in list

The Main approach for checking elements of a list in a string is : s=””‘<a href=”https://ertfwetwer” target=”_blank”>[Nerve Center]</a>”’ my_list=[‘href’,’a’] def checker(mylist, my_string) new = list() for i in mylist: if i in my_string: # if elements is in string (you can check only special elements ) print i ,’is in string’ new.append(i) #storing result to … Read more

[Solved] code is ignoring def start?

Try adding the following lines after all your defs. if __name__==’__main__’: start() Also, everytime you call a function it needs to be followed by parenthesis, example: sign = Button(rootE, text=”register”, command=Signup) login = Button(rootE, text=”log in”, command=Login) Should be: sign = Button(rootE, text=”register”, command=Signup()) login = Button(rootE, text=”log in”, command=Login()) solved code is ignoring def … Read more

[Solved] How to find and replace in 2 txt files with Python [closed]

I am converting the data in your MASTERIDS.txt to a dictionary. Key is the old id and value is the new ID. Then search for the dict for the new id using the value from OLDIDS.txt Demo: with open(“PATH_TO_OLDIDS.txt”, “r”) as src: data = src.readlines() d ={} with open(“PATH_TO_MASTERIDS.txt”, “r”) as toReplaceSRC: for i in … Read more