[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

[Solved] How to print in range? [closed]

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

[Solved] Decoding reversed mulitline string encoded in base64 format automatically [closed]

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

[Solved] Python list not picking up min and max values correctly

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

[Solved] Python – var = var = var value

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

[Solved] Determine whether the input matches a specified format

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

[Solved] What is different if and elif? [duplicate]

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

[Solved] could not conver string to float

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

[Solved] real-valued function in python [closed]

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