<p dir="ltr">Hey,</p>
<p dir="ltr">>        invalidCommands = 0<br>
>        command = ("left", "right", "up", "down")<br>
>        numUnique = 0<br>
>        numInvalid = 0<br>
>        invalidCommands = set()</p>
<p dir="ltr">It seems you have defined invalidCommads as borh of int type and a set type. </p>
<p dir="ltr">Also a nice trick for multiple options in the future is:<br>
If command is in ("up","down","left","right"):<br>
    print command</p>
<p dir="ltr">Of course thos wont worj now vecause yoy have ti keep track of tge counters, but I personaly like it and find it usefull.</p>
<p dir="ltr">Good luck,<br>
Dino<br><br></p>
<p dir="ltr">> Message: 2<br>
> Date: Mon, 1 Dec 2014 01:01:32 +0000<br>
> From: <<a href="mailto:niyanaxx95@gmail.com">niyanaxx95@gmail.com</a>><br>
> To: "=?utf-8?Q?<a href="http://tutor@python.org?=">tutor@python.org?=</a>" <<a href="mailto:tutor@python.org">tutor@python.org</a>><br>
> Subject: [Tutor] Sets Python<br>
> Message-ID: <<a href="mailto:547bbf1d.91268c0a.220f.3741@mx.google.com">547bbf1d.91268c0a.220f.3741@mx.google.com</a>><br>
> Content-Type: text/plain; charset="utf-8"<br>
><br>
> I am not understanding how I am supposed to do the highlighted things on the problem statement. If someone could please direct me on the steps to go about doing what is highlighted.  Have do I read each command, by making the program read each line?? How do I add the invalid commands into a set? When printing the command is invalid, do I simply do as I did with the valid commands print?<br>
><br>
><br>
> Problem Statement:<br>
> We are going to write a program that reads an input file of commands (Commands.txt) to Arnold the Robot.<br>
><br>
> The four valid command are:<br>
><br>
> Up<br>
><br>
><br>
> Down<br>
><br>
><br>
> Left<br>
><br>
><br>
> Right<br>
><br>
><br>
> After you read each command, make sure it is valid (included in the set of valid commands).<br>
><br>
> If the command is valid, print ?Valid command entered, the command was:? and the command.<br>
><br>
> If the command is invalid, print ?Invalid command entered, the command was:? and the command.<br>
><br>
> If the command is invalid, add it to a set of invalid commands.<br>
><br>
> Keep a count of:<br>
><br>
> The total number of commands read<br>
><br>
><br>
> The total number of valid commands read<br>
><br>
><br>
> The total number of invalid commands read<br>
><br>
><br>
> After all of the commands have been read:<br>
><br>
> Print the total number of commands read<br>
><br>
><br>
> Print the total number of valid commands read<br>
><br>
><br>
> Print the total number of invalid commands read<br>
><br>
><br>
> Print the number of unique invalid commands read<br>
><br>
><br>
> Print the set of invalid commands.<br>
><br>
><br>
> The format of the input files is:<br>
><br>
> Each line in the file contains a command, not all command are valid<br>
><br>
><br>
><br>
><br>
><br>
> My Code So Far:<br>
><br>
> def main() :<br>
>    # Define main variables<br>
>        leftCount = 0<br>
>        rightCount = 0<br>
>        upCount = 0<br>
>        downCount = 0<br>
>        commandCount = 0<br>
>        invalidCommands = 0<br>
>        command = ("left", "right", "up", "down")<br>
>        numUnique = 0<br>
>        numInvalid = 0<br>
>        invalidCommands = set()<br>
><br>
>        filename = input("Enter filename (default: Commands.txt): ")<br>
>        if len(filename) == 0 :<br>
>               filename = "Commands.txt"<br>
>        inputFile = open(filename, "r")<br>
><br>
><br>
>        command = input("Please enter a command for Arnold: ")<br>
>        if command in command :<br>
>                      commandCount = commandCount + 1<br>
>                      print("The total amount of commands: ", commandCount)<br>
>        if command == "up" :<br>
>                      upCount = upCount + 1<br>
>                      print("Valid command entered, the command was: up")<br>
>        elif command == "down" :<br>
>                      downCount = downCount + 1<br>
>                      print("Valid command entered, the command was: down")<br>
>        elif command == "left" :<br>
>               leftCount = leftCount + 1<br>
>               print("Valid command entered, the command was: left")<br>
>        elif command == "right" :<br>
>               rightCount = rightCount + 1<br>
>               print("Valid command entered, the command was: right")<br>
>        else :<br>
>               print("Invalid command entered, the command entered was: ", command)<br>
>               numInvalid = numInvalid + 1<br>
>               if not command in invalidCommands :<br>
>                      numUnique = numUnique + 1<br>
>               invalidCommands.add(command)<br>
><br>
><br>
><br>
><br>
><br>
>        for line in inputFile :<br>
>               theWords = line.split()<br>
>               for word in theWords :<br>
>                      cleaned = clean(word)<br>
>               if cleaned != "" :<br>
>                      numUnique.append(cleaned)<br>
>        print("The file contains", len(numUnique), "unique words.")<br>
><br>
><br>
><br>
> # Cleans a string by making letters lowercase and removing characters that are not letters<br>
> #  @param string the string to be cleaned<br>
> #  @return the cleaned string<br>
> def clean(string) :<br>
>        result = ""<br>
>        for char in string :<br>
>               if char.isalpha() :<br>
>                      result = result + char<br>
>                      return result.lower()<br>
><br>
><br>
><br>
><br>
><br>
> # Start the program.<br>
> main()<br>
><br>
><br>
><br>
> What Happens When Ran:<br>
><br>
> 3.4.1 (v3.4.1:c0e311e010fc, May 18 2014, 10:38:22) [MSC v.1600 32 bit (Intel)]<br>
> Python Type "help", "copyright", "credits" or "license" for more information.<br>
> [evaluate CommandsDraft.py]<br>
> Enter filename (default: Commands.txt): Commands.txt<br>
> Please enter a command for Arnold: dawn<br>
> The total amount of commands:  1<br>
> Invalid<br>
> Traceback (most recent call last):<br>
>   File "C:\Program Files (x86)\Wing IDE 101 5.0\src\debug\tserver\_sandbox.py", line 70, in <module><br>
>   File "C:\Program Files (x86)\Wing IDE 101 5.0\src\debug\tserver\_sandbox.py", line 52, in main<br>
> builtins.AttributeError: 'int' object has no attribute 'append'<br>
> -------------- next part --------------<br>
> An HTML attachment was scrubbed...<br>
> URL: <<a href="http://mail.python.org/pipermail/tutor/attachments/20141201/fecd2537/attachment.html">http://mail.python.org/pipermail/tutor/attachments/20141201/fecd2537/attachment.html</a>><br>
><br>
> ------------------------------<br>
><br>
> Subject: Digest Footer<br>
><br>
> _______________________________________________<br>
> Tutor maillist  -  <a href="mailto:Tutor@python.org">Tutor@python.org</a><br>
> <a href="https://mail.python.org/mailman/listinfo/tutor">https://mail.python.org/mailman/listinfo/tutor</a><br>
><br>
><br>
> ------------------------------<br>
><br>
> End of Tutor Digest, Vol 130, Issue 1<br>
> *************************************<br>
</p>