Find the answer to your Linux question:
Results 1 to 3 of 3
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1

    having issues with indentation in a tiny python script


    dear community,

    fairly new to python - have tried to fix the issues but i struggle with that

    having issues with indentation in a tiny python script - in this line

    Code:
        running = True
    see the code

    Code:
    def enter_a_friend():
        name = input("Enter friend's name: ")
        phone = input("Enter phone number: ")
        email = input("Enter email address: ")
        address = input("Enter friend's address:")
        return Person(name, phone, email)
     
    def lookup_a_friend(friends):
        found = False
        name = input("Enter name to lookup: ")
        for friend in friends:
            if name in friend.getName():
                print(friend)
                found = True
        if not found:
            print("No friends match that term")
     
    def show_all_friends(friends):
        print("Showing all contacts:")
        for friend in friends:
            print(friend)
     
    def main():
        friends = []
          running = True
        while running:
            print("\nContacts Manager")
            print("1) new contact    2) lookup")
            print("3) show all       4) end ")
            option = input("> ")
            if option == "1":
                friends.append(enter_a_friend())
            elif option == "2":
                lookup_a_friend(friends)
            elif option == "3":
                show_all_friends(friends)
            elif option == "4":
                running = False
            else:

    having issues with this line
    Code:
        running = True

    what should i do - i think that indentation means that i have to " add " 4 x space!?

    Many thanks for all and any help

  2. #2
    Linux User
    Join Date
    Jul 2016
    Posts
    443
    Quote Originally Posted by gibraltar View Post
    dear community,

    fairly new to python - have tried to fix the issues but i struggle with that

    having issues with indentation in a tiny python script - in this line

    Code:
        running = True
    see the code

    Code:
    def enter_a_friend():
        name = input("Enter friend's name: ")
        phone = input("Enter phone number: ")
        email = input("Enter email address: ")
        address = input("Enter friend's address:")
        return Person(name, phone, email)
     
    def lookup_a_friend(friends):
        found = False
        name = input("Enter name to lookup: ")
        for friend in friends:
            if name in friend.getName():
                print(friend)
                found = True
        if not found:
            print("No friends match that term")
     
    def show_all_friends(friends):
        print("Showing all contacts:")
        for friend in friends:
            print(friend)
     
    def main():
        friends = []
          running = True
        while running:
            print("\nContacts Manager")
            print("1) new contact    2) lookup")
            print("3) show all       4) end ")
            option = input("> ")
            if option == "1":
                friends.append(enter_a_friend())
            elif option == "2":
                lookup_a_friend(friends)
            elif option == "3":
                show_all_friends(friends)
            elif option == "4":
                running = False
            else:

    having issues with this line
    Code:
        running = True

    what should i do - i think that indentation means that i have to " add " 4 x space!?

    Many thanks for all and any help
    you should stop being a liar and start doing your own work, how about that? first, this is your OTHER account 'gibraltar'....weve already seen that you are actually sayhello: http://www.linuxforums.org/forum/pro...pi-python.html

    and youve been asking about python for about 4 yrs. again your lazy and just want someone else to do your work for you. your 'new" to python, huh? from 2014: http://www.linuxforums.org/forum/pro...-database.html and youve asked similar crap on other forums. about python php wordpress and overpass, ALL with the same language.

    quit lying. you dont even bother to post your whole program just a small piece. and if you bothered to just try some things you could have figured it out. but no. you want everyone else to do your work just like you always have. wont read the docs wont try things, just wander around with your hand out like a bum.

  3. #3
    Linux User
    Join Date
    Jul 2016
    Posts
    443
    -->
    i see you did your typical 'post on a dozen forums with my hand out like a bum saying i'm a newbie" tactic:
    https://stackoverflow.com/questions/...nning-the-code

    and on at least 5 other forums, where you posted 'your" code.

$spacer_open
$spacer_close

Posting Permissions

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