[Solved] Multi-Dimensional String Arrays
if i ask to print array 1, 1 then i would get back “d”? No that would return an error, as arrays start at 0. So you must return words[0][0], that would get you back “d”. solved Multi-Dimensional String Arrays
if i ask to print array 1, 1 then i would get back “d”? No that would return an error, as arrays start at 0. So you must return words[0][0], that would get you back “d”. solved Multi-Dimensional String Arrays
The following: i = 0 for y in range(0, 500, 125): for x in range(0, 750, 125): print(‘(%3d, %3d): %3d ‘ % (x, y, i), end=”) i += 1 print() produces ( 0, 0): 0 (125, 0): 1 (250, 0): 2 (375, 0): 3 (500, 0): … Read more
From the OP’s comment: list = [‘LnNlbHBtYXhlIGVzdSBvdCBlZXJmIGxlZUYgLnNldGlzYmV3IGNpZmZhcnQgaGdpaCBubyBub2l0YXNpbGFtcm9uZWQgZm8gdHBlY25vYyBlaHQgZWJpcmNzZUQgLjQ=’, ‘ZWxpZiBlbm8gbmkgZWIgdHN1TSApaXYgICAg’, ‘c25vaXRhY2lmaWNlcHMgOC1QRVAgdGVlbSB0c3VNICl2ICAgIA==’, ‘Ni4yIG5vaHR5UCBodGl3IGtyb3cgdHN1TSApdmkgICAg’, ‘c2VsdWRvbSByZWh0byB5YiBlbGJhdHJvcG1pIGViIGRsdW9ocyBzc2FsQyApaWlpICAgIA==’] s=””.join(list) s = s.decode(‘base64’, ‘strict’) print (s[::-1]) the join operation connects all of the strings together, but only the first string is translated. This is because, when decoding a base 64 string, everything in the string past the first one or two = characters … Read more
Generally you want to have some code example of what it is you are trying to do and where you are stuck to ask a question here. However this was not hard to visualize and I felt like building an example. Here I have created a GUI that has 2 buttons and one label. I … Read more
Take a look at the Google Charts API. You can use it to generate a URL that represents your graph. Simply download the image associated with that URL and you have your chart. 2 solved generating chart using python or google charts [closed]
Use: for i in range(0,150): print(“echo update \necho snapshot \necho gall \necho clearobj”) print(“echo read rot_”+”%03d”%i+”.speck \n”) “%03d”%a in Python2 converts to a three digit string. 1 solved duplicate individual paragraphs in txt file
You need to insert ints in the list instead of strings, just modify: item = input(“Enter a number to add to the list: “) noNumbers.append(item) By: item = int(input(“Enter a number to add to the list: “)) noNumbers.append(item) 7 solved Python list not picking up min and max values correctly
Use a dictionary, not variables. If you have variable names, the way to get the variable contents is evil, and almost always there is a better way. In this case: server_connection_commands = { “AdminServer”: “putty.exe -ssh 1.1.1.1”, “Server1”: “putty.exe -ssh 2.2.2.2” } server = requests.get(‘http://example.com’).text subprocess.Popen(server_connection_commands[server]) 2 solved Python – var = var = var … Read more
Using a regex would work like this: import re regex = r’\d-\d{4}-\d{4}-\d’ preg = re.compile(regex) s1 = ‘9-9715-0210-0’ s2 = ‘997-150-210-0’ m1 = preg.match(s1) m2 = preg.match(s2) if m1: print(‘String s1 is valid’) else: print(‘String s1 is invalid’) if m2: print(‘String s2 is valid’) else: print(‘String s2 is invalid’) You can try the code at … Read more
You could use sorted. The following solution works, provided the value of ‘id’ starts with a single character followed by numbers. sorted(b, key=lambda x: int(x[‘id’][1:])) 1 solved How to sort a list by dict values in Python? [closed]
To generate random names you will need to have a database of names. However, if you can pass off any combination of letters as names then you can achieve this using random.choice. Refer below code which prints out 15 names and the length of names is between 3 and 25 characters. You can extend the … Read more
Yes, there is. The “WELCOME” in the problem statement is all-caps. 1 solved Output matches expected output. Yet submission is not being accepted
It’s different. It basically else if but concated to elif. if you use elif you check the same condition and if one is met it exits. If you use ifs the whole time it checks each if statement whether or not the previous one was true. It’s just normal Python Syntax. x = 0 if … Read more
Its hard to answer this without getting more information. I’m assuming your error is on this line: converted_price = float(price[0:6]) price[0:6] is an array. You cant convert an array to a float like that. In addition, each element may not even be a number, it could be something like this: [<a class=”sister” href=”http://example.com/elsie” id=”link1″>Elsie</a>, <a … Read more
Here is how you can incorporate the conditions into the function: def f(x): if x <= 15: return x * 2 + 10 if x <= 35: return 3 * x ** 2 return 2 * x**3 – 5 When calling the function: >>> f(31.039) 2890.2585630000003 >>> f(42.103) 149263.82765345403 >>> For the display_f: def f(x): … Read more