#๐Ÿ”’ learning python beginner

13 messages ยท Page 1 of 1 (latest)

timber flare
#

for the second loop it shows freind_pizza as normal text and dosent accociate with the list

pizzas = [ "peperoni", "cheese", "bacon" ]

for pizza in pizzas:
print(pizza)
print("\n")
print(f"i like {pizza} pizza.")

for freind in freind_pizza:
print(freind_pizza)
print("\n")
print(f"i like {pizza} pizza.")

print(f"\ni really like pizzas because there yummy my favorite are {pizzas} all of there are very tasty")

freind_pizza = pizzas[:]
freind_pizza.append("pineapple")
print(freind_pizza)

pizzas.append("meatball")
print(pizzas)

elfin jacinthBOT
#

@timber flare

Python help channel opened

Remember to:

  • Ask your Python question, not if you can ask or if there's an expert who can help.
  • Show a code sample as text (rather than a screenshot) and the error message, if you've got one.
  • Explain what you expect to happen and what actually happens.

:warning: Do not pip install anything that isn't related to your question, especially if asked to over DMs.

nova knoll
#

where is freind_pizza defined?

#

oh is that the question? freind_pizza is just not defined, python doesn't know what it's supposed to be

nova knoll
#

what did you want freind_pizza to be?

#

oh I see, you define it later

#

python code is read top-to-bottom, so if you want to use freind_pizza, you need to put that code under the line where you created freind_pizza

#
pizzas = [ "peperoni", "cheese", "bacon" ]

for pizza in pizzas:
    print(pizza)
    print("\n")
    print(f"i like {pizza} pizza.")

print(f"\ni really like pizzas because there yummy my favorite are {pizzas} all of there are very tasty")

freind_pizza = pizzas[:]
freind_pizza.append("pineapple")
print(freind_pizza)

for freind in freind_pizza:
    print(freind_pizza)
    print("\n")
    print(f"i like {pizza} pizza.")

pizzas.append("meatball")
``` so this would work
elfin jacinthBOT
#
Python help channel closed

This help channel has been closed and it's no longer possible to send messages here. If your question wasn't answered, feel free to create a new post in #1035199133436354600. To maximize your chances of getting a response, check out this guide on asking good questions.