Results 1 to 5 of 5

Thread: Python Programming problem.

  1. #1
    Join Date
    Sep 2012
    Beans
    16

    Python Programming problem.

    Code:
    #!/usr/bin/env python
    print "=======jnLink v.1.0======="
    x=raw_input('User name: ')
    y=raw_input('Password: ')
    if x=='Jon' and y=='turtles21':
        print "Logged On, Welcome Jonathan Nunamaker."
    else:
        print "logon failed"
        c=1
        while c <10:
            print "Logon Failed"
    "actual coding"

    Code:
    start=raw_input("EF to edit file: ")
    if start=='EF':
        filedestination=raw_input('File name please? ')
        editorwrite=raw_input('Edit or Read this file? (r to read and w to write. )')
        fob=open('/home/jon/My Cheat Tables/computer/' + filedestination, editorwrite)
        if editorwrite== 'q':
            print "Main Menu: "
        if editorwrite== 'w':
            fob.write(raw_input('Your file is open: '))
            fob.close()
        if editorwrite== 'r':
             print "=======file======="
             print fob.read()
             print "=======file======="
             closeorjump=raw_input('type c to exit to main menu: ')
             if closeorjump== 'c':
                 fob.close()
    ==========================================
    I have this; I need to have it go back to main menu after the end of each if statement. Any ideas? Please?
    Last edited by lisati; September 27th, 2012 at 08:17 AM. Reason: Added code tags for readability & to keep formatting

  2. #2
    Join Date
    Jun 2007
    Location
    Porirua, New Zealand
    Beans
    Hidden!
    Distro
    Ubuntu

    Re: Python Programming problem.

    Thread moved to Programming Talk.

    I've addded "code" tags ([code] and [/code]) which can help with readability
    Forum DOs and DON'Ts
    Never assume that information you find using a search engine is up-to-date.

  3. #3
    Join Date
    Sep 2009
    Beans
    217

    Re: Python Programming problem.

    What you want is a loop. A while loop would probably be a good choice.
    http://wiki.python.org/moin/WhileLoop

  4. #4
    Join Date
    May 2008
    Location
    UK
    Beans
    1,448
    Distro
    Ubuntu 8.04 Hardy Heron

    Re: Python Programming problem.

    And use functions to help you divide your code into logical sections.
    Tony - Happy to try to help.
    Unless otherwise stated - all code posted by me is untested. Remember to Mark the Thread as Solved.
    Ubuntu user number # 24044 Projects : TimeWarp - on the fly Backups

  5. #5
    Join Date
    Feb 2008
    Beans
    251
    Distro
    Ubuntu 12.04 Precise Pangolin

    Re: Python Programming problem.

    For capturing the password on the command line you might want to consider using the python getpass library as well:

    Code:
    from getpass import getpass
    
    name = raw_input("Username: ")
    pswd = getpass("Password: ")
    
    print "\nResults:"
    print "name: %s \npass: %s" % (name, pswd)

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •