Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #66779
| Path | csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.xs4all.nl!newsfeed4.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail |
|---|---|
| Return-Path | <joel.goldstick@gmail.com> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.052 |
| X-Spam-Evidence | '*H*': 0.90; '*S*': 0.00; 'subject:file': 0.07; 'cc:addr:python-list': 0.11; 'def': 0.12; 'line.split()': 0.16; 'index': 0.16; 'wrote:': 0.18; '3.0': 0.19; 'starts': 0.20; 'feb': 0.22; 'email addr:gmail.com>': 0.22; 'cc:addr:python.org': 0.22; 'print': 0.22; 'cc:2**0': 0.24; 'cc:no real name:2**0': 0.24; "i've": 0.25; '>': 0.26; '2.0': 0.26; 'header:In-Reply- To:1': 0.27; 'message-id:@mail.gmail.com': 0.30; 'skip:( 20': 0.30; 'url:mailman': 0.30; 'lines': 0.31; 'subject:numbers': 0.31; 'says': 0.33; 'url:python': 0.33; 'table': 0.34; 'subject:from': 0.34; 'received:google.com': 0.35; 'url:listinfo': 0.36; 'url:org': 0.36; 'list': 0.37; 'skip:o 20': 0.38; 'pm,': 0.38; 'url:mail': 0.40; 'range': 0.61; 'name': 0.63; 'subject:The': 0.64; 'to:addr:gmail.com': 0.65; 'here': 0.66; '20,': 0.68; '11.': 0.74; 'scores': 0.91 |
| DKIM-Signature | v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; bh=XEZdPLluxCMAQiAgFZBw4mg9OuISU0sj8t9LjdTJLVM=; b=OOlXitVqSqBQqhLefi6KLMO/tRkseh23dE9dzAAfuqx/Jj/YLsgizxw5lTsdkCWn7L YE0GUteqf7nYVgOLsVFhgboUrDrgLxLwsKkET+zz3+Jj6xYvwajKI/r4vGLNxvQPIBUB 6+UNQmCHcO9DRWfxtNe7wLQtrNisSeQjlatAdupjsNff8aRzyzb169bHF670nnvRdSBv fk506M6sTHYpcLeDUELmp+o4wdQofprSRzv1shw8WqEByRbJs/3tROG8R9UUiuPhrNd3 XV8vUOgi3JIBJ6M55t872kLw9G8vuY9Uc+ylmGJozDBLdwoOsI+h4BiMLUkEHGHET+Ww uJgg== |
| MIME-Version | 1.0 |
| X-Received | by 10.52.183.106 with SMTP id el10mr1540309vdc.73.1392921169514; Thu, 20 Feb 2014 10:32:49 -0800 (PST) |
| In-Reply-To | <9036049f-7d08-4de7-83f8-61e5fa2c2d2f@googlegroups.com> |
| References | <882091da-a499-477e-8f50-c5bdde7cdfec@googlegroups.com> <le5bhe$461$1@reader1.panix.com> <9036049f-7d08-4de7-83f8-61e5fa2c2d2f@googlegroups.com> |
| Date | Thu, 20 Feb 2014 13:32:49 -0500 |
| Subject | Re: The sum of numbers in a line from a file |
| From | Joel Goldstick <joel.goldstick@gmail.com> |
| To | kjakupak@gmail.com |
| Content-Type | multipart/alternative; boundary=bcaec547cb9782581b04f2dabbdd |
| Cc | python-list@python.org |
| X-BeenThere | python-list@python.org |
| X-Mailman-Version | 2.1.15 |
| Precedence | list |
| List-Id | General discussion list for the Python programming language <python-list.python.org> |
| List-Unsubscribe | <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe> |
| List-Archive | <http://mail.python.org/pipermail/python-list/> |
| List-Post | <mailto:python-list@python.org> |
| List-Help | <mailto:python-list-request@python.org?subject=help> |
| List-Subscribe | <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.7201.1392921172.18130.python-list@python.org> (permalink) |
| Lines | 64 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1392921172 news.xs4all.nl 2973 [2001:888:2000:d::a6]:57323 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | csiph.com comp.lang.python:66779 |
Show key headers only | View raw
[Multipart message — attachments visible in raw view] - view raw
On Feb 20, 2014 1:20 PM, <kjakupak@gmail.com> wrote:
>
> What I've got is
> def stu_scores():
> lines = []
> with open("file.txt") as f:
> lines.extend(f.readlines())
> return ("".join(lines[11:]))
>
> scores = stu_scores()
> for line in scores:
> fields = line.split()
> name = fields[0]
Print fields here to see what's up
> sum1 = int(fields[4]) + int(fields[5]) + int(fields[6])
> sum2 = int(fields[7]) + int(fields[8])
> average1 = sum1 / 3.0
> average2 = sum2 / 2.0
> print ("%s %f %f %") (name, average1, average2)
>
> It says that the list index is out of range on the sum1 line. I need
stu_scores because the table from above starts on line 11.
> --
> https://mail.python.org/mailman/listinfo/python-list
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
The sum of numbers in a line from a file kxjakkk <kjakupak@gmail.com> - 2014-02-20 08:22 -0800
Re: The sum of numbers in a line from a file John Gordon <gordon@panix.com> - 2014-02-20 16:46 +0000
Re: The sum of numbers in a line from a file kjakupak@gmail.com - 2014-02-20 10:16 -0800
Re: The sum of numbers in a line from a file Joel Goldstick <joel.goldstick@gmail.com> - 2014-02-20 13:32 -0500
Re: The sum of numbers in a line from a file kjakupak@gmail.com - 2014-02-20 10:37 -0800
Re: The sum of numbers in a line from a file Peter Otten <__peter__@web.de> - 2014-02-20 19:59 +0100
Re: The sum of numbers in a line from a file Chris “Kwpolska” Warrick <kwpolska@gmail.com> - 2014-02-20 19:56 +0100
Re: The sum of numbers in a line from a file MRAB <python@mrabarnett.plus.com> - 2014-02-20 19:17 +0000
Re:The sum of numbers in a line from a file Dave Angel <davea@davea.name> - 2014-02-20 11:54 -0500
Re: The sum of numbers in a line from a file Travis Griggs <travisgriggs@gmail.com> - 2014-02-20 14:35 -0800
Re: The sum of numbers in a line from a file Johannes Schneider <johannes.schneider@galileo-press.de> - 2014-02-21 09:16 +0100
Re: The sum of numbers in a line from a file sffjunkie@gmail.com - 2014-02-24 03:48 -0800
Re: The sum of numbers in a line from a file sffjunkie@gmail.com - 2014-02-24 04:02 -0800
csiph-web