Python Forum
Printing on same line from 2 functions.
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Printing on same line from 2 functions.
#1
Hey guys quick question,

this is the code that I've written so far:

total = 0

def print_student(student):
    informatie_student = student.split("__________")

    naam_student = informatie_student[0]
    cijfers_student = informatie_student[1]

    print_cijferstudent(cijfers_student)

    print naam_student

def print_cijferstudent(input_cijfer):
    enkel_cijfer = input_cijfer.split(" ")
    cijfer1 = float(enkel_cijfer[0])
    cijfer2 = float(enkel_cijfer[1])
    cijfer3 = float(enkel_cijfer[2])

    gemiddelde = round((total + cijfer3 + cijfer2 + cijfer1) / len(enkel_cijfer), 1)
    print gemiddelde

students = open('input.txt').readlines()

for student in students:
    print_student(student)
the input is: Tom Bombadil__________6.5 5.5 4.5

and the output is:

5.5
Tom Bombadil

I want it so that it will print: Tombadil 5.5. on one line.

Thanks in advance guys !
Reply


Messages In This Thread
Printing on same line from 2 functions. - by Dyefull - Dec-03-2019, 12:56 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Seven Segment Display - QUERY on Multi-line side-by-side printing output ajayachander 3 4,837 Mar-13-2020, 07:02 AM
Last Post: ajayachander
  Command line inputs not printing to Log File ijosefson 1 3,363 Oct-19-2017, 06:41 AM
Last Post: buran

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020