heights = [] giants = {} count = 0 total = 0 name = input("Input name: ") try: height = float(input("Input height: ")) except: print("Please only enter number values.") exit(1) while name != "..." and name: count += 1 total += height giants[name] = height heights.append(height) try: name = input("Input name: ") except: pass try: height = float(input("Input height: ")) except: if name != "..." and name: print("Please only enter number values.") else: break pass answer = input("Have you completed the procedure?") average = sum(heights) / count print("The Average is %s." % average)
Run
Reset
Share
Import
Link
Embed
Language▼
English
中文
Python Fiddle
Python Cloud IDE
Follow @python_fiddle
Browser Version Not Supported
Due to Python Fiddle's reliance on advanced JavaScript techniques, older browsers might have problems running it correctly. Please download the latest version of your favourite browser.
Chrome 10+
Firefox 4+
Safari 5+
IE 10+
Let me try anyway!
url:
Go
Python Snippet
Stackoverflow Question