Skip to content

Tag: python

Replace a single character in a string

I am trying to make a function that automatically generated a response to a selection of an action in a text adventure game. My problem is that I have to replace every second ‘_’ with ‘ ‘. However I have tried everything I have though of and whenever I google the question the only solu…

problems with get_context_data in ListView (django)

I need to show in a template two models: models.py: and created a ListView of this views.py I need to created a filter of the same ‘dimension’ so that in the template show only the subdimensions of that dimension. my template dimension.html: but if u notice, show all the subdimensiones in all card…

Create Mutual Inclusive arguments with argparse

I want to build a program that has 2 mutually inclusive args and 2 that are not dependent on the first two. Something like this: where ‘consume’ and ‘–count’ are dependent on each other i.e, without ‘consume’ ‘–count’ will throw an error ‘show&…

Is there a 2-D “where” in numpy?

This might seem an odd question, but it boils down to quite a simple operation that I can’t find a numpy equivalent for. I’ve looked at np.where as well as many other operations but can’t find anything that does this: The output is a 2-D array (3,4), of booleans comparing each value. Answer …

plotly python how to show bars where y values are zero

I would like to still show all x axis values even when the y values are zero for that bar. What am I doing wrong here? As you can see, x axis threshold one = 55% is missing from the x axis, but I would like it to still be there even though the y values are 0. Thanks in