Jul-15-2021, 07:59 PM
(This post was last modified: Jul-15-2021, 07:59 PM by paracelsusx.)
Hello, I am learning python3 using the python crash course book and I have decided to try to learn the most accepted way to properly format my code early on.
To do this I installed pycode with PIP.
Is it ok to be using 90 characters instead of 80? I find it a lot easier to work in 90 although I understand 80 is the standard, although there seems to be some debate over it when I search it online. I was thinking 90 is a small increase and may be accepted more among other programmers.
I'm doing the guest list tutorial in the crash course book, if your curious this is how my code looks. I hope it is somewhat proper and clean looking for my early stages. It is working at least.
To do this I installed pycode with PIP.
Is it ok to be using 90 characters instead of 80? I find it a lot easier to work in 90 although I understand 80 is the standard, although there seems to be some debate over it when I search it online. I was thinking 90 is a small increase and may be accepted more among other programmers.
I'm doing the guest list tutorial in the crash course book, if your curious this is how my code looks. I hope it is somewhat proper and clean looking for my early stages. It is working at least.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 |
# guest list exercise at the end of the list section # see intro list for how to' print ( 'Guest list exercise v1.0' ) print ("\nI should have room at the venue for three \ people") guestlist = [ 'dracula' , 'zelda' , 'luigi' ] # original guest list' # names = guestlist.title()' print ( "\nI think I will invite the following" ) print (guestlist[ 0 ].title() + ", " + guestlist[ 1 ].title() + ", and " + guestlist[ 2 ].title() + "." ) # cant figure out how to print the list without the # brackets yet and as a title all at once. Will have to # go back. For now calling each one separate' invmsg = (", would you like to cometo dinner \ tonight? \nI am inviting ") inv1 = ( "\nHello " + guestlist[ 0 ].title() + invmsg + guestlist[ 1 ].title() + ", and " + guestlist[ 2 ].title() + " as well. " ) print (inv1) # case sensitive # i will go back and make this code better inv2 = ( "\nHello " + guestlist[ 1 ].title() + invmsg + guestlist[ 0 ].title() + ", and " + guestlist[ 2 ].title() + " as well. " ) print (inv2) inv3 = ( "\nHello " + guestlist[ 2 ].title() + invmsg + guestlist[ 0 ].title() + ", and " + guestlist[ 1 ].title() + " as well. " ) print (inv3) # sent the first three invitations # one of the guest cant make it mcmake = ( "\nI received a call that ," + guestlist[ 2 ].title() + ", can't make it to the" + "dinner. \nI will need to invite someone else" + "notify the others." ) # \n can be used anywhere in the print text print (mcmake) rguest = guestlist.pop( 2 ) guestlist.insert( 2 , 'samus' ) nguest1 = guestlist[ - 1 ].title() cmmsg = ( "I am very sorry but ," + rguest.title() + ", can't make it to the party. I invited , " + nguest1 + ", instead to join us." ) g1 = guestlist[ 0 ].title() g2 = guestlist[ 1 ].title() print ( "\nDear " + g1 + ". " + cmmsg) print ( "\nDear " + g2 + ". " + cmmsg) # print(guestlist) this is a tester # correct - inv3 has to be updated inv3 = ( "\nHello " + guestlist[ 2 ].title() + invmsg + guestlist[ 0 ].title() + ", and ," + guestlist[ 1 ].title() + ", as well. " ) print ( "\n" + inv3) print ("\n I found a even bigger venue, i can invite \ three more people to the dinner") guestlist.insert( 0 , 'gandolf' ) guestlist.insert( 2 , 'yoshi' ) guestlist.append( 'cain' ) g1 = guestlist[ 0 ].title() g2 = guestlist[ 1 ].title() g3 = guestlist[ 2 ].title() g4 = guestlist[ 3 ].title() g5 = guestlist[ 4 ].title() g6 = guestlist[ 5 ].title() # dont know how to do them all separately # or to tell it when it ends automatically inv1 = ( "\nHello " + g1 + invmsg + g2 + ", " + g3 + ", " + g4 + ", " + g5 + ", and ," + g6 + ", as well." ) inv2 = ( "\nHello " + g3 + invmsg + g1 + ", " + g2 + ", " + g4 + ", " + g5 + ", and ," + g6 + ", as well." ) inv3 = ( "\nHello " + g5 + invmsg + g1 + ", " + g2 + ", " + g3 + ", " + g4 + ", and ," + g6 + ", as well." ) print (inv1) print (inv2) print (inv3) print ( "\nSo for dinner I have invited these fine " + "people. " + g1 + " , " + g2 + " , " + g3 + " , " + g4 + " , " + g5 + " , and " + g6) print ("\nDue to a unforeseen incident at the \ location of the dinner hall, I now have to have\ the dinner at home and can only invite two \ guest.") print ( "\nI think I will only invite " + g2 + " and " + g6 + " to dinner, I will need uninvite the" + " other right away" ) removedguest = guestlist.pop( 0 ) + " ," \ + guestlist.pop( 1 ) + " ," \ + guestlist.pop( 1 ) + " " \ + guestlist.pop( 1 ) # im sure there is a better way to do this print ("\nI have uninvited the following people \ form the party: " + removedguest.title()) uninvmsg = "I am sorry to have to inform you due\ to unforeseen events I must uninvite your from \ the dinner party. \nI will make sure to invite \ you next time." print ( "\nDear " + g1 + ", " + uninvmsg) print ( "\nDear " + g3 + ", " + uninvmsg) print ( "\nDear " + g4 + "," + uninvmsg) print ( "\nDear " + g5 + ", " + uninvmsg) stillinvmsg = "I just wanted to let you know you\ are still invited to my dinner party, hope to see\ you there." print ( "\nDear " + g2 + ", " + stillinvmsg) print ( "\nDear " + g6 + ", " + stillinvmsg) del guestlist[ 0 ] # removing the last two names del guestlist[ 0 ] # print(guestlist) test line # exercise finished |