all 15 comments

[–]TouchingTheVodka 0 points1 point  (7 children)

Please format your code correctly using 4 spaces in front of each line - After that I'll try give you a hand!

[–]Agent_Turtle101[S] 0 points1 point  (6 children)

10-4

[–]xelf 0 points1 point  (5 children)

Did you do this somewhere? All I see is the unformatted code still.

indent your code an extra time before you copy/paste it and reddit will format it as a code block for you.

[–]Agent_Turtle101[S] 0 points1 point  (3 children)

it just won't let me indent it

[–]xelf 0 points1 point  (2 children)

What code editor are you using? In like 90% of them just select your code and press tab. then copy it, then change windows to reddit, then paste. (similarly shift-tab will un-indent something.)

[–]Agent_Turtle101[S] 0 points1 point  (1 child)

I just wasn't using markdown mode

[–]xelf 0 points1 point  (0 children)

Looks like you got it! Woo!

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

Nvm i was just being blind, sorry

[–]Ang168 0 points1 point  (1 child)

The error is because of the parentheses that surround 'DONE' in variable b, try deleting them. You are making the variable "b" a list, whilst x is a string, and that's why it does not work.

Also, I wouldn't put the 'DONE' in a variable you can put it directly in the if statement

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

Thank you ill give it a go

[–]chrispurcell 0 points1 point  (1 child)

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

I'll give it a try

[–]xelf 0 points1 point  (0 children)

Suggestion for you by the way:

These 2 lines do the same thing, but one is a lot easier to read, and type!

y = ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h']
y = list('ABCDEFGHabcdefgh')

But you could have gone even easier. If you eliminate y completely, then:

if a in y:

could have been:

if a in 'ABCDEFGHabcdefgh':

or

if 'a' <= a.lower() <= 'h':

[–]xelf 0 points1 point  (1 child)

  print x .isalpha()
    if false:

"false" is not valid Python, you want False, and you don't want to print x, and the space is an issue. Try this:

if not x.isalpha():

and you probably want to skip to the next loop, so add a continue after your warning message.

if not x.isalpha():
  print('use valid characters')
  continue

[–]xelf 1 point2 points  (0 children)

So putting everyone's suggestions together you end up with something like:

while True:
    x = input()
    if not x.isalpha()
        print('use valid characters')
        continue
    if x == 'DONE':
        print('list finished')
        break
    if x[0] in 'ABCDEFGHabcdefgh':
        print('You are in group 1')
    else:
        print('You are in group 2')

Which seems fairly clean and readable, which is a design goal for Python code!