Re: [Tutor] My code isn't working properly

2016-06-20 Thread Sopan Shewale
Yup! His problem must be indentation. Apart from him, everybody from
mailing list is worried about his problem ;)

Regards,



On Mon, Jun 20, 2016 at 7:08 AM, boB Stepp  wrote:

> On Mon, Jun 20, 2016 at 2:59 AM, Sopan Shewale 
> wrote:
> > You need to worry about indentation ;)  & spells (.. you seriously want
> to
> > use input instead of raw_input? )
>
> The book the OP is using is Python 3-based.  He should be using
> "input()" as he did.  Otherwise, it does look like a lack of
> indentation for his statements that are part of the while loop are his
> problem.
>
> boB
> ___
> Tutor maillist  -  Tutor@python.org
> To unsubscribe or change subscription options:
> https://mail.python.org/mailman/listinfo/tutor
>
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] My code isn't working properly

2016-06-20 Thread Sopan Shewale
check it here - http://textsnip.com/6bd6jh




On Mon, Jun 20, 2016 at 1:01 AM, Alan Gauld via Tutor 
wrote:

> On 20/06/16 08:16, Minhaj Ahmed via Tutor wrote:
> > Hi,I'm studying Michael Dawsons 'Python programming for absolute
> > beginners',in chapter 5,page 129,the author writes a program that records
> > high scores in a game. I have done exactly as the author has set out and
> > yet my code isn't doing what the author says it should be doing. The code
> > is printed below.
> >
> > scores=[]
> > choice=None
> > while choice !="0":
> > print(
>
> There is a mistake in the indentation here that should give you an
> error. This means the code you have posted is not the actual code
> you are running.
>
> It may be a mail problem, in which case please resend your message
> making sure you post in plain text(not HTML) to preserve the layout.
>
> Because indentation is critical in Python we can't begin to
> guess what is wrong with your code until we see the correctly
> indented code.
>
>
> --
> Alan G
> Author of the Learn to Program web site
> http://www.alan-g.me.uk/
> http://www.amazon.com/author/alan_gauld
> Follow my photo-blog on Flickr at:
> http://www.flickr.com/photos/alangauldphotos
>
>
> ___
> Tutor maillist  -  Tutor@python.org
> To unsubscribe or change subscription options:
> https://mail.python.org/mailman/listinfo/tutor
>
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] My code isn't working properly

2016-06-20 Thread Sopan Shewale
You need to worry about indentation ;)  & spells (.. you seriously want to
use input instead of raw_input? )


See if following works for you?
--


#!/usr/bin/python


scores = []

choice = None


while choice !="0":

  print \

  """

  High scores

  0-Exit

  1-Show scores

  2-Add scores

  3-Delete scores

  4-Sort scores

  """



  choice = raw_input("Choice: ")

  print

  if choice== "0":

  print("Goodbye")


  elif choice=="1":

 print("High scores")

 for score in scores:

print(score)


  elif choice=="2":

 score=int(raw_input("What score did you get?: "))

 scores.append(score)


  elif choice=="3":

 score=int(raw_input("Remove which score?: "))

 if score in scores:

scores.remove(score)

 else:

print(score, "isnt in the high score list")

  elif choice=="4":

 scores.sort(reverse=True)

  else:

 print("Sorry but",choice,"isnt a valid choice")


  raw_input("\nPress enter to exit")


---


Cheers,


--sopan shewale

On Mon, Jun 20, 2016 at 12:16 AM, Minhaj Ahmed via Tutor 
wrote:

> Hi,I'm studying Michael Dawsons 'Python programming for absolute
> beginners',in chapter 5,page 129,the author writes a program that records
> high scores in a game. I have done exactly as the author has set out and
> yet my code isn't doing what the author says it should be doing. The code
> is printed below.
>
> scores=[]
> choice=None
> while choice !="0":
> print(
> """
> High scores
> 0-Exit
> 1-Show scores
> 2-Add scores
> 3-Delete scores
> 4-Sort scores
> """
> )
> choice = input("Choice: ")
> print()
> if choice== "0":
> print("Goodbye")
>
>
> elif choice=="1":
> print("High scores")
> for score in scores:
> print(score)
>
>
> elif choice=="2":
> score=int(input("What score did you get?: "))
> scores.append(score)
>
> elif choice=="3":
> score=int(input("Remove which score?: "))
> if score in scores:
> scores.remove(score)
> else:
> print(score, "isnt in the high score list")
> elif choice=="4":
> scores.sort(reverse=True)
> else:
> print("Sorry but",choice,"isnt a valid choice")
>
> input("\nPress enter to exit")
>
> the only part of the program that seems to work is when i enter "0" to exit
> the program,any other number it just prints the beginning,which I know it
> should,but thats it. It doesn't ask for a new score when I enter "2" and
> even when I enter a supposedly invalid choice it still prints out the text
> in the while loop. Hope someone can help.
>
> Regards
>
> Minhaj
> ___
> Tutor maillist  -  Tutor@python.org
> To unsubscribe or change subscription options:
> https://mail.python.org/mailman/listinfo/tutor
>
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor