Python for Informatics - Chapter 8 - Lists

preview_player
Показать описание
Рекомендации по теме
Комментарии
Автор

Excellent class. You should be be a pro-wrestler and call your finishing move "the Severance Package".

valitacorrea
Автор

>>> print "python with chuck"
fun
(see python also knows that)

freddythobhani
Автор

love the "magic" fixes to your slides!

errolcasey
Автор

Dr. Chuck you could be in the 'Wild Hogs' biker gang with that avatar

southpawje
Автор

Great work Chuck! Keep it it. Really helpful!

fairchildable
Автор

gr8 work Prof
I would like to do a PhD under u

mahimsd
Автор

Do you teach anything like this in java

Curchel
Автор

numlist = []
stop = False

while True:
inp = input("Enter a number:")

try:
number = float(inp)
numlist.append(number)

except ValueError:
if inp == "":
print("\nNo number detected?\nType 'done' to calculate\nType 'stop' to exit\n")

elif inp.lower() == "done":
break

elif inp.lower() == "stop":
stop = True
break

if not stop:

try:
average = sum(numlist) / len(numlist)
print("Average: ", average)

except ZeroDivisionError:
print("Stopped user from dividing by zero, phew, close call..\n")

markus
Автор

# why isnt this working? it works if i have line[0]='F', but it wont allow me to be more specific with line[0:3]. why not?
code>>
file=open('mbox-short.txt', 'r')
print 'works'
for line in file:
 if line[0:3]=='From':
  print line
 else: 
  continue 

fritzauguste
join shbcf.ru