Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trial
fabrizio anichini
1,751 Pointswhere is the problem?
hello friends! i have to do a challange named "loop" and i dont know where is the problem on my code
i wirte this :
for words in hellos :
if hellos == "hello" :
print("hello world")
if hellos == "Tungjatjeta":
print("Tungjatjeta world")
if hellos == "Grüßgott" :
print( "Grüßgott world")
if hellos == "Вiтаю" :
print( "Вiтаю world")
if hellos =="dobrý den" :
print("dobrý den world")
if hellos == "hyvää päivää" :
print( "hyvää päivää world")
if hellos == "你好" :
print( "你好 world")
if hellos == "早上好" :
print( "早上好 world")
thank for help !
Alexander Davison
65,469 PointsHey Cheo, here's a simpler way of describing it:
If you want code to be formatted, you do this:
```python
# Put your code here
```
and it should look like this:
# Put your code here
Good luck! ~Alex
2 Answers
Alexander Davison
65,469 PointsPython is smarter than you think. You don't need any if conditions for this challenge. In fact, you only need to write two lines of code. If you do this, you can reduce lots of code:
for word in hellos:
print("{} world!", hellos)
However, if you try this code, it still will cause an error. This is because in this code we did: .format(hellos). Hellos is a list, not the one hello we want (the hello will be different every time). Instead, you were supposed to say
for word in hellos:
print("{} world!".format(word))
I hope this helps you out!
Good luck, Alex
fabrizio anichini
1,751 Pointsthank at all!
Alexander Davison
65,469 PointsNo problem :)
Cheo R
37,150 PointsCheo R
37,150 PointsHello Fabrizio, you can use the Markdown Cheatsheet to format your code. It really helps readability. To do so, you can do three backticks, followed the word python (on the same line as the first three backticks), followed by your code (on the next lines), and end it with three more back ticks. So my code print("this is only a test {}".format(x)) would look like
print("this is only a test {}".format(x))