Jump to content

Python code entered in a notepad - looks pretty messy - how to proceed


dil_bert

Recommended Posts

 

hello dear PHP-experts,

 

 

i am pretty new in python - so do not bear with me. i tried to dive into python whith a little contact-manager. But at the moment i think i what is even more important - to find a good ide - that helps me. I have the code written in a notepad - but that is not the apropiate method i guess. So first of all - i need an advice - to a good editor.

 

BTW; the code looks not very pthonic - since i have no good editor. And yes: i guess that there are some quotes are missing.

 

how to proceed? love to hear from you .

greetings

def main():

friends = []

for i nin range(2):

print ("content manager")

name = input ("Enter name: ")

phone = input ("Enter phone: ")

email = input ("Enter email: ")

friends.append([name, phone, email])


for i nin range(len (friends)) :
print ("Contact info")
for j nin range(len (friends[1])) :
print (friends [i][j]")

if __name__ ==* __main__*

main()



name - instance variabels

phone

email


getName getters

getPhone

getEmail

setPhone setters

setEmail


class Person (object)

# the Person class defines a person in terms of a name, phone-number and email-adress

# constructor

def __init__ (self, thename, thePhone, theEmail):

self. name = theName

self. phone = thePhone

self. email = theEmail


# accessor methods (getters)

def getName(self):

return self.name

def getPhone(self):

return self.phone

def getEmail(self):

return self.email

# mutator methods (setters)

def setPhone (self,newPhoneNumber):

self.hone = newPhoneNumber

def setEmail (self,newEmailAdress):

self.email = newEmailAdress



def__str__ (self):

return Person [name + self.name+\

phone + self.phone * \

email + self.email * \

"]"


def main():

friend = Person ("Jill", 555-1111", "jbusi@gmail.org")

print (frindd1.getEmail())

frind1.setEmail("jbush@gmail.com)

print frind1.getEmail()

if __name__ ==* __main__*


main()



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 friends in frineds:

print friends



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)

eilf opton =="3":

show_all_friends(friends)

 

Link to comment
Share on other sites

I would suggest you try Atom.

 

Here's a short and sweet intro to adding some things to support it. A quick google will find you much more information:

 

https://medium.com/@andrealmar/how-to-setup-atom-as-your-python-development-environment-a67fe8738bd3

 

We don't need to have a whole new editor thread as there have been many already, but there probably isn't an IDE out there that doesn't provide some level of support for Python if search a bit.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.