Python idle help

help_me_please
python

#1

Capture

I need help with some python idle code.

basically i have a list and I am trying to print out each letter alternating like a b c a b c

Count is just counting what letter I’m on with numbers.

Every time I try to run the program it gives me an error on the print line
2

I’m not too good at idle and python so please help!


#2

Is it this?


#3

Ok, so you’re saying that you’re trying to make letters pattern in order? If so, I can’t help, maybe find a tutorial.


#5

This is the correct way:

alist = [“1”, “2”, “3”]
count = 0
for x in range(3):
print(alist [0 + count])
count = count + 1

Python lesson: if you see the name of your list/variable/etc in purple (in this type of theme), it is a keyword. Do not use them.
You can see all the keywords in your Python version by typing in the shell (without the ">>>)
">>> import keyword
">>> print(keyword.kwlist)

If you have more questions, I have a programming topic if you want to check out!
:wink:


#6

No. That double equal was alright.
The problem was that he was using a keyword as a name, which “confuses" the code and the IDLE interprets it as something else.


#7

Okay.

Yeah I don’t really remember anything I learned about python.


#8

I also forget some Python things (like tuples) XD


#9

Really? My code editor always highlights that as an error.

Also, @RobotPro,

count = count + 1

Could be changed to

count += 1

Just to keep things more short.


#10

In his case, the error was at line 6 bc of the Keyword.


#11

You could also change that. But I like to keep it like that:

That is more of a personal choosing bc it doesn’t alter the code XD


#12

Yes, it was just a suggestion. In the end, it’s down to personal preference.


#13

Note to self
try solutions later (once your math homework is finished you nugget)


#14

Thank you for the help! When I run your code however it doesn’t exactly give me what I want

I’m trying to make the code alternate between a b c 100 times.

I’m getting an error after the system prints a b c

Which doesn’t make much sense to me because the line of code that has the issue is line 6 which works for three rounds and then stops working.

Thank you for the help though on the alist things. I didn’t know there were keywords not to use in python!


#15

Sorry for the late reply, but could you post your current code (after the corrections). I will try to help you! :slight_smile:


#16

Me too! (I just saw this topic again XD)


#17

You’re welcome! Keywords are important :slight_smile:


#18

@William04GamerA @LunaMorgana387

Yes! Sorry also about the late reply. I will post the code as soon as possible!


#19

Ok! We are here to help!


#20

Me too. I’m here! :slight_smile:


#21

now I’m having trouble finding the right program because of the names lol
potato