I have recently built a password generator but wanted to include an aspect where if the user types in a letter instead of a number when defining the length of the password and number of passwords then the output would be to loop back in. If not the password generator would continue if numbers were inputted. T…
Tag: python-3.x
Extract parameters from variable length python f-string
Using Python 3.6 I have an f-string in main that looks like used in the following function call send_mail(title, message, to, from) I am not allowed to change the function call. The question is, inside send_email can I extract the folder, and host variables from the f-string? I would normally try something li…
Python array as a counter
I’m a Python 3.0 beginner and I’m struggling to find a solution to the following problem. It’s a step for a Galton Board simulation exercise. I have an numpy array, which length is auto generated based on another variable I am then generating a set of numbers, adding them to a list and summi…
Python Importing package at same level but different directory
python version:3.9.6 I cannot seem to get this to work I know there are a million posts that are the same as this but the solutions never seem to work for me. I’ve run into this before and always end up just restructuring the folders to include all files in one path which is obviously not ideal. So here…
Tensorflow: Incompatible shapes: [1,2] vs. [1,4,4,2048]
I have the following tensorflow model: I have simplified this somewhat in an attempt to narrow down the problem, When I run this I get the following error: This error always seems to occur on a different input image. All my images are exactly the same dimennsions. I am using tensorflow 2.4.1 What am I missing…
How can i find the key of a random picken value from a dictionary in Python?
I am a beginner of Python. I have made a dictionary of Lists. I want to pick a random value and then to know the key of that value. Is that possible? e.g. Is there a way to know which is the key of the random value ? My purpose is to delete that pick_value from the list.Any suggestion is
Extracting key and value from tuple of dictionaries (taken from json file) in python
I have a JSON file which is a tuple of multiple dictionaries and I want to extract keys and values from some of them. The file looks something like this (this is just an example of the structure with random keys and values): What I want to extract all names (Ana, Bob, Chloe) and their ids something like this:…
Is it possibile to have both InlineKeyboard and ReplyKeyboard on telegram?
Is it possible to have both keyboards (telegram.InlineKeyboard and telegram.ReplyKeyboard) under a single message? Thanks Answer no, that’s not possible. the reply_markup parameter of send_message & friends only accepts one keyboard. The closest you can get is to send two messages with one keyboard …
Is it possible to append a df (which is declared outside) from a function
I am trying to append a pandas df which is outside of a function. Here, I want to append df2 (inside the function) with df (is located outside of the function). I am getting UnboundLocalError: local variable ‘df’ referenced before assignment error (and that is expected because of the variable scop…
Trying to filter out A-Z and special characters in python
This is what I’ve tried so far: It doesn’t work, can you explain why? Answer Should work. This code will check with is_alpha if the i character is an alphabetic letter (A-Z, case unsensitive) and if it returns false, will add it to the new_string variable. Later, it will check if the string contai…