Python text based game: Adding to inventory from a dictionary

I am trying to add items to the players inventory from a dictionary. However, when I add the first item to the dictionary, the program stops repeating the while loop. Can anyone help with this or give me some other way to add items to the inventory? Thanks so much.

def main_menu():  # prints the main menu for the player and shows instructions
move_commands = ''
print('Welcome to the Zombie Apocalypse Text Game!')
    'You must navigate through the shopping center and collect all 6 items to defeat the zombie horde and escape')
print('Move commands: go North, go South, go East, go West')
print('Add inventory: get "item name"')
return move_commands

def player_status(current_room, inventory, rooms):
print_player_status = ''
print('You are in the {}'.format(current_room))
print('Inventory:', inventory)
while rooms(current_room)('Item') in inventory:
    print('You see', rooms(current_room)('Item'))
return print_player_status

def main():
# A dictionary for the zombie apocalypse based text game
# The dictionary links a room to other rooms.
rooms = {
    'Ice Cream Parlor': {'go East': 'Movie Theatre', 'Item': 'no items'},
    'Movie Theatre': {'go West': 'Ice Cream Parlor', 'go East': 'Convenience Store', 'go North': 'Clothes Shop',
                      'go South': 'Restaurant', 'Item': 'water bottles'},
    'Clothes Shop': {'go South': 'Movie Theatre', 'go East': 'Shoe Store', 'Item': 'bandages'},
    'Shoe Store': {'go West': 'Clothes Shop', 'Item': 'map'},
    'Convenience Store': {'go West': 'Movie Theatre', 'go North': 'Outdoor Shop', 'Item': 'antibiotics'},
    'Outdoor Shop': {'go South': 'Convenience Store', 'Item': 'ammunition'},
    'Restaurant': {'go North': 'Movie Theatre', 'go East': 'Bowling Alley', 'Item': 'food'},
    'Bowling Alley': {'Item': 'a zombie horde!'}

current_room = 'Ice Cream Parlor'
inventory = ()  # inventory begins empty
directions = ('go North', 'go South', 'go East', 'go West')
get_item = 'get water bottles', 'get bandages', 'get antibiotics', 'get food', 'get ammunition', 'get map'

while current_room != 'exit':
    player_status(current_room, inventory, rooms)
    player_move = input('Enter your move: ')
    if current_room == 'Bowling Alley' and len(inventory) == 5:
        print('Congratulations! You have collected all 6 items and defeated the zombie horde!')
    elif current_room == 'Bowling Alley' and len(inventory) < 5:
        print('You did not collect all the items and could not defeat the horde! Try again!')

    if player_move in directions:
        if player_move in rooms(current_room):
            current_room = rooms(current_room)(player_move)   # (player_move:(room))
            print('You cannot go that way!')
    elif player_move in get_item:
    elif player_move == 'exit':
        print('Thanks for playing!')
        print('Invalid move')


text editor – App to view custom logfiles?

I have a logfile in my file system on the phone.

I am looking for an app which can display this logfile, but I would like to have something which can “parse” my logfile, at least first few space-delimited fields to provide basic filters:

1970-01-01 18:00:00 LOGTAG1 log message for tag1
1970-01-01 18:01:00 LOGTAG2 log message for tag2

I want to be able to

  • list all logtags found in the file
  • display only specific logtag
  • set the delimiter, and max delimitable fields, for example the above case, delimiter is (space), and delimited fields number is 3 (date, time, tag), all the rest would just be the log message.

Which application is capable of doing this?

I have a powerful phone with a huge display, so this is something pretty much feasable.

ffmpeg – In concat demuxer how do I add a fade out to the text file

How can the fade outs from The OLD concatfile.txt below be added to:
The NEW concatfile.txt

ffconcat version 1.0
file ‘images 001.jpg’
duration 00:00:05.100
file ‘images 002.jpg’
duration 00:00:05.200
file ‘images 003.jpg’
duration 00:00:05.150 1.2 fade out needed
file ‘images 004.jpg’
duration 00:00:05.120
file ‘images 005.jpg’
duration 00:00:05.000
file ‘images 006.jpg’ 1.2 fade out needed
duration 00:00:05.080

This text file adds a fade out to all images
starting at 4 sec for 1 sec and loops the images.

The OLD concatfile.txt

$ ffmpeg
-loop 1 -t 5 -i happy1.jpg
-loop 1 -t 5 -i happy2.jpg
-loop 1 -t 5 -i happy3.jpg
-loop 1 -t 5 -i happy4.jpg
-loop 1 -t 5 -i happy5.jpg
-loop 1 -t 5 -i happy6.jpg

(0:v)scale=1280:720:force_original_aspect_ratio=decrease,pad=1280:720:(ow-iw)/2:(oh-ih)/2,setsar=1,fade=t=out:st=4:d=1(v0); <br/>

(1:v)scale=1280:720:force_original_aspect_ratio=decrease,pad=1280:720:(ow-iw)/2:(oh-ih)/2,setsar=1,fade=t=in:st=0:d=1,fade=t=out:st=4:d=1(v1); <br/>

(2:v)scale=1280:720:force_original_aspect_ratio=decrease,pad=1280:720:(ow-iw)/2:(oh-ih)/2,setsar=1,fade=t=in:st=0:d=1,fade=t=out:st=4:d=1(v2); <br/>

(3:v)scale=1280:720:force_original_aspect_ratio=decrease,pad=1280:720:(ow-iw)/2:(oh-ih)/2,setsar=1,fade=t=in:st=0:d=1,fade=t=out:st=4:d=1(v3); <br/>

(4:v)scale=1280:720:force_original_aspect_ratio=decrease,pad=1280:720:(ow-iw)/2:(oh-ih)/2,setsar=1,fade=t=in:st=0:d=1,fade=t=out:st=4:d=1(v4); <br/>

(5:v)scale=1280:720:force_original_aspect_ratio=decrease,pad=1280:720:(ow-iw)/2:(oh-ih)/2,setsar=1,fade=t=in:st=0:d=1,fade=t=out:st=4:d=1(v5); <br/>

(6:v)scale=1280:720:force_original_aspect_ratio=decrease,pad=1280:720:(ow-iw)/2:(oh-ih)/2,setsar=1,fade=t=in:st=0:d=1,fade=t=out:st=4:d=1(v6); <br/>

wp query – Filter WP_Query content depends on text inside

I have hundreds of pages and want to sort theme into 3 tabs: premium, senior and junior

Here is my query

    $query_args = array(
    'post_type' => 'page',
    'post_status' => 'publish',
    'meta_query' => array(
            'key' => '_wp_page_template',
            'value' => 'writerssingle.tpl.php',
    'order' => 'ASC',
    'orderby' => 'rand',
    'posts_per_page' => 72,
    'suppress_filters' => false,
    'paged' => (get_query_var('paged')) ?? 1
    $writers_tabs = array(
    add_filter('posts_orderby', 'force_random_day_seed');
    $the_query = new WP_Query($query_args);
    remove_filter('posts_orderby', 'force_random_day_seed');

And here is the tabs logic

<div class="tab-content" id="nav-tab-content">
    <?php foreach ($writers_tabs as $index => $tab) : $item = 0; ?>

    <div class="tab-pane <?php echo $index === 0 ? 'active' : ''; ?>"
        id="nav-<?php echo $tab; ?>" role="tabpanel"
        aria-labelledby="nav-<?php echo $tab; ?>-tab">

        <?php if ($the_query->have_posts()) {
                while ($the_query->have_posts()) {

                    if ($item < 12 && strpos(get_the_content(), '<h3>' . ucfirst($tab) . ' Writer</h3>')) {
                        get_template_part( 'partials/content', 'writer' );

            } else {
                get_template_part('partials/content', 'none');


    <?php endforeach ?>
</div><!-- close .tab-content -->

What I try to do is to filter content using key words <h3>Premium Writer</h3>, <h3>Senior Writer</h3> or <h3>Junior Writer</h3>. So in first tab should be premium, in second senior and in third junior.

This part of the code isn’t the best idea coz I omit a lot of pages

if ($item < 12 && strpos(get_the_content(), '<h3>' . ucfirst($tab) . ' Writer</h3>')) {
  get_template_part( 'partials/content', 'writer' );

The question is: how to writer correct filter in this case?

html – Widget Text Needs to be White

I need to change the color to white on the title of a widget that I have in my footer. I looked at the source code and note that it says H4 before and after the text. However, when I change the color of H4 in the global typography, it does not change the color of this widget text. I also found the area for the Widget Header and changed it to white but it also is not changing the text to white on the widget. I see the below when I view source code but when I go into CSS, it will not bring it up when I search. Here is what the code currently says:

<section id="media_image-3" class="fusion-footer-widget-column widget widget_media_image"><h4 class="widget-title">Members of:</h4>

emails – Webform module : send html mail with plain text mime/alternative (for anti-spam)

We use Webform Drupal 8 module to handle newsletter subscription on a website. An html formatted email is sent to confirm subscription. Unfortunately, this email is sent with only content-type:text/html, and you know how picky Spamassassin is about this. It’s a real deliverability issue. We’d like to be able to send that email with a content-type:multipart/alternative, with 2 parts : one with text/html content-type and one with text/plain. How can we do this ? We installed “mail system” and “mime mail” modules, but we can’t figure out how to use them, or even if it’s the right solution. Has anyone ever managed to do this?

7 – Image field input renders with type text instead of file

(Drupal newb – please go easy and give references that help me learn how to debug stuff in Drupal myself, thank you!)

I’ve taken over a Drupal site with 7.80.

There’s a type called Event which has a bunch of fields including an Image. There are many existing Events where Image upload presumably worked fine in the past. The images are visible when editing those Events.

Problem: The form for adding a new Event renders the Image control as a text box (i.e. input type='text' with an attach button instead of a file control (i.e. input type='file').

Also notable that if I use e.g. chrome inspector to change the type of the input to file and then try to upload a file it fails with:

“The file in the Image field was unable to be uploaded.”

How can I start to debug this? Google didn’t turn up any obvious hits that I could find so pointers on how to start debugging much appreciated!

entities – How can I avoid double line breaks () in a text field (field type: text unformatted long)?

How can I avoid double line breaks (<br><br>) in a text field (field type: text unformatted, long)?

Users write text into this text field. When they hit Enter twice, the result is:
But <br><br> is not themable with css, the height of <br> can NOT be set with css.

Therefore <br><br> should be avoided and paragraphs <p> used instead of it. <br><br> should never be saved to database.
How can double <br><br> be avoided or replaced with <p> before the the field is saved?

filters – Text input field for filtering custom post type in custom archive page

I made a glossary custom archive for a custom post type ‘words’ and I’m trying to add a search bar/text input field that will filter the words and only show the ones that have the _word_korean_value_key or the _word_english_value_key metaboxes contain the searched string. I already implemented a category filter but I can’t figure out how to go about the search bar.


Here is my archive-words.php:

<?php get_header(); ?>

<div class="container kbites-container">
    <h2 class='glossary-title'>Glossary </h2>
    <div class="filter-custom-taxonomy speech-part-links">
      <a href='<?php echo home_url() ?>/words' class='speech-part-link'>All </a>
              $terms = get_terms( 'speech_parts' ); //retrieves terms in speech parts taxonomy
              foreach ( $terms as $term ) { ?>
              <a href="<?php echo home_url() ?>/words/?getby=cat&cat=<?php echo esc_attr( $term->slug ); ?>" class="speech-part-link">
              <?php echo esc_html( $term->name ); ?>
          <?php }; ?>

   <!-- Use Bootstrap Accordion for words display -->
    <div class="accordion" id="accordionExample">

    if(have_posts()) {
        while(have_posts()) {

<div class="accordion-item">
    <h2 class="accordion-header" id="heading-<?php echo get_the_ID(); ?>">
      <button class="accordion-button collapsed " type="button" data-bs-toggle="collapse" data-bs-target="#collapse-<?php echo get_the_ID(); ?>" aria-expanded="true" aria-controls="collapse-<?php echo get_the_ID(); ?>">
        echo get_post_meta( get_the_ID(), '_word_korean_value_key', true); ?> - <?php
        echo get_post_meta( get_the_ID(), '_word_english_value_key', true);
    <div id="collapse-<?php echo get_the_ID(); ?>" class="accordion-collapse collapse" aria-labelledby="heading-<?php echo get_the_ID(); ?>" >
      <div class="accordion-body">
      <?php echo the_content(); ?>
      <?php $id = get_post_meta( get_the_ID(), '_word_source_value_key', true); //retrieve source post id
      echo '<a class = "glossary-source-link" href="'.get_permalink( $id ).'">'.'Go to post: '.get_the_title( $id ).'</a>'; ?>

    <?php }}
     wp_reset_query(); ?>


<div class="pagination">
<?php the_posts_pagination( array( 'mid_size' => 2, 'prev_text' => __( '< Prev', 'textdomain' ),
    'next_text' => __( 'Next >', 'textdomain' ),) ); ?>


<?php get_footer(); ?>

The custom post type:

//Glossary word post type
function kbites_words_post() {
    $labels = array(
        'name' => 'Words',
        'singular_name' => 'Word',
        'add_new' => 'Add New Word',
        'all_items' => 'All Words',
        'add_new_item' => 'Add Word',
        'edit_item' => 'Edit Word',
        'new_item' => 'New Word',
        'view_item' => 'View Word',
        'search_item' => 'Search Word'


    $args = array(
        'labels' => $labels,
        'public' => true,
        'has_archive' => true,
        'publicly_queryable' => true,
        'query_var' => true,
        'rewrite' => true,
        'capability_type' => 'post',
        'hierarchical' => false,
        'show_in_rest' => true,
        'supports' => array('editor', 'thumbnail', 'revisions'),
        'menu_position' => 3,
        'exclude_from_search' => true,
        'menu_icon' => 'dashicons-translation',


add_action('init', 'kbites_words_post');

And the code I used for the category filter:

function kbites_words_filter_archive( $query ) {
      if ( ! $query->is_main_query() )
      return $query;
      if ( is_admin() ) {
      if ( is_post_type_archive('words') ) {
        if (isset($_GET('getby'))) {
              if ( 'cat' === $_GET('getby') ) {
                          $taxquery = array(
                                          'taxonomy' => 'speech_parts',
                                          'field' => 'slug',
                                          'terms' => $_GET('cat'),
                          $query->set( 'tax_query', $taxquery );
      $query->set( 'posts_per_page', 30 );
      return $query;
add_action( 'pre_get_posts', 'kbites_words_filter_archive');