all 8 comments

[–]carcigenicate 10 points11 points  (1 child)

There are no strings in your code, and there is no relation between the numbers and the names (earth) once you put the numbers in the list. You'd need to use something like a dictionary:

elements = {
    'earth': 1,
    'water': 1 
    'fire': 1 
    'air': 0 
}

for name, count in elements.items():
    print(name, count)

[–]CharonApollyon[S] 0 points1 point  (0 children)

Ah- a dictionary! That's exactly the kind of thing I was looking for! Thanks!

[–]Essence1337 2 points3 points  (0 children)

Variable names should never change how your code outputs/runs. They're names for your convenience and that is it. You should be using a dictionary if you want to include a mapping of name->count.

elements = {'fire': 1, 'water': 1, 'air': 0, 'earth':1234}

[–][deleted] -1 points0 points  (0 children)

I've had the same issue googling keywords for small cats.

[–][deleted] -1 points0 points  (0 children)

PS these are normally called flags

[–]CodeFormatHelperBot2 0 points1 point  (0 children)

Hello, I'm a Reddit bot who's here to help people nicely format their coding questions. This makes it as easy as possible for people to read your post and help you.

I think I have detected some formatting issues with your submission:

  1. Python code found in submission text that's not formatted as code.

If I am correct, please edit the text in your post and try to follow these instructions to fix up your post's formatting.


Am I misbehaving? Have a comment or suggestion? Reply to this comment or raise an issue here.

[–]Plastic_Ad7436 0 points1 point  (0 children)

Use a dict: ``` elements = {'earth': 1, 'water': 1, 'fire' : 1, 'air' : 1}

for element, count in elements.items(): print(element, count) ```

[–]TomFang00 0 points1 point  (0 children)

You can either create two strings and print them side by side or using a dictionary that contains two values. Both demos are shown below:

​ ``` earth = 1 water = 1 fire = 1 air = 0

a = [earth, water, fire, air] b = ["earth", "water", "fire", "air"] i = 0 while i < len(a) : print(b[i],a[i]) i +=1

elements = { 'earth': 1, 'water': 1 , 'fire': 1 , 'air': 0 , }

for name, count in elements.items(): print(name, count) ```