[Solved] Finding and counting the frequency of known pairs of words in multiple files [closed]

When using combinations() you are getting all pairs, even the non-adjacent ones. You can create a function that will return the adjacent pairs. I’ve tried the following code and it worked, maybe it can give you some insight: import os import re from collections import Counter def pairs(text): ans = re.findall(r'[A-Za-z]+’, text) return (tuple(ans[i:i+2]) for … Read more

[Solved] In python? why do the subclass inherit from parent? when you use the init of method to assign the parent?but it does not work [duplicate]

In python? why do the subclass inherit from parent? when you use the init of method to assign the parent?but it does not work [duplicate] solved In python? why do the subclass inherit from parent? when you use the init of method to assign the parent?but it does not work [duplicate]

[Solved] How to print a list without [ , ” in python

Assuming that your list is: this_is_a_list = [‘*’, ‘I’, ‘B’, ‘M’, ‘ ‘, ‘i’, ‘s’, ‘ ‘, ‘a’, ‘ ‘, ‘t’, ‘r’, ‘a’, ‘d’, ‘e’, ‘m’, ‘a’, ‘r’, ‘k’, ‘ ‘, ‘o’, ‘f’, ‘ ‘, ‘t’, ‘h’, ‘e’, ‘ ‘, ‘I’, ‘n’, ‘t’, ‘e’, ‘r’, ‘n’, ‘a’, ‘t’, ‘i’, ‘o’, ‘n’, ‘a’, ‘l’, ‘ ‘, … Read more

[Solved] How to get the sum and the names of all the users from all voice channels Disocrd?

You need to access the voice channel object. I recommend you use the voice channel’s id. The command could look as follows: @client.command(pass_context = True) async def vcmembers(ctx, voice_channel_id): #First getting the voice channel object voice_channel = discord.utils.get(ctx.message.server.channels, id = voice_channel_id) if not voice_channel: return await client.say(“That is not a valid voice channel.”) members = … Read more

[Solved] Print string and integer in python [duplicate]

1) Because there is not a clear, unambiguous meaning of str+int. Consider: x = “5” + 7 Should the + str-ify the 7 or int-ify the “5”? One way yields 12, the other yields “57”. 2) Because there are other alternatives that more clearly express the programmer’s intent: print “5”, 7 print “5%d” % 7 … Read more

[Solved] IndentationError: expected an indented block help please [closed]

This appears to be the correct indentation. #!/usr/bin/env python import hashlib import sys def main(): if len(sys.argv) < 2: print “[ + ] Usage: %s <hash>” % sys.argv[0] sys.exit(0) commonStrings = [ “Diaa”, “Diab”, “Mohammad”, “test”, “7amama”, “sos”, “lolo”, “hacked”, “try”, “[email protected]”, “secgeek”, “lnxg33k”, “[email protected]”, “[email protected]”, “[email protected]” ] for i in commonStrings: if hashlib.md5(i).hexdigest() == … Read more

[Solved] Initialize variables when they’re not already declared in python

One solution is to use a defaultdict: from collections import defaultdict my_dict = defaultdict(lambda: []) my_dict[‘var1’].append(1) print(my_dict[‘var1’]) # prints ‘[1]’ This would not allow you to simply do print(var1), however, because it would still be undefined in your local (or global) namespace as a tagged value. It would only exist in the defaultdict instance as … Read more