Seite 1 von 1

Ausgabe über mehrere Zeilen

Verfasst: Montag 26. Juli 2010, 21:39
von Luap12
Hi!

Könnt ihr mir mal bitte sagen wie man eine Ausgabe ( print("...") ) über mehrere Zeilen hinweg machen kann!?

Es gibt ja schonmal die Möglichkeit es so zumachen:

print("""Hallo
Leute
!!!""")

Das geht aber nicht wenn man darin noch eine Variable ausgeben möchte, was bei mir der Fall ist.
Nächste mir bekannte Möglichkeit wäre:
print("Hallo")
print("Leute")
print("!!!")

Ist aber sehr anstrengend wenn es wie bei mir über 26 Zeilen gehen muss!!^^

Re: Ausgabe über mehrere Zeilen

Verfasst: Montag 26. Juli 2010, 21:43
von cofi

Re: Ausgabe über mehrere Zeilen

Verfasst: Dienstag 27. Juli 2010, 09:30
von Luap12
Ja, danke, nur leider versteh ich kein Wort. Kannst du es mir bitte au Deutsch erklären!?


lg Luap12

Re: Ausgabe über mehrere Zeilen

Verfasst: Dienstag 27. Juli 2010, 09:44
von snafu

Code: Alles auswählen

>>> greet = """\
... Hallo,
... {name}
... !!!""".format(name='snafu')
>>> print(greet)
Hallo,
snafu
!!!

Re: Ausgabe über mehrere Zeilen

Verfasst: Dienstag 27. Juli 2010, 09:53
von Luap12
ah, oke, danke!!

Re: Ausgabe über mehrere Zeilen

Verfasst: Dienstag 27. Juli 2010, 09:55
von cofi
Deutsch hat wohl nicht den Ausschlag gegeben :twisted:

Re: Ausgabe über mehrere Zeilen

Verfasst: Dienstag 27. Juli 2010, 10:57
von Luap12
cofi hat geschrieben:Deutsch hat wohl nicht den Ausschlag gegeben :twisted:
wieso?? meinst du ich hatte keine Lust das alles zu lesen!? gestern abend nicht mehr, das stimmt, aber heute morgen habe ich es schon versucht!!


Ja, das funzt auch ganz gut, aber ich weiß nicht wie ich es bei dem programm hier machen soll. das sind mehrere variablen in einem Satz und dann auch noch mehrere Sätze. Hier mal den Programmcode (Könnte das einer von euch mal für a und b machen!? bitte):

#Beginn des Programms

print("Bitte geben sie einen Text ein.")

text = input()

laenge = len(text)

print("Anzahl der Zeichen im Text:", laenge)

sucha = "a"
anza = text.count(sucha)
suchb = "b"
anzb = text.count(suchb)
suchc = "c"
anzc = text.count(suchc)
suchd = "d"
anzd = text.count(suchd)
suche = "e"
anze = text.count(suche)
suchf = "f"
anzf = text.count(suchf)
suchg = "g"
anzg = text.count(suchg)
suchh = "h"
anzh = text.count(suchh)
suchi = "i"
anzi = text.count(suchi)
suchj = "j"
anzj = text.count(suchj)
suchk = "k"
anzk = text.count(suchk)
suchl = "l"
anzl = text.count(suchl)
suchm = "m"
anzm = text.count(suchm)
suchn = "n"
anzn = text.count(suchn)
sucho = "o"
anzo = text.count(sucho)
suchp = "p"
anzp = text.count(suchp)
suchq = "q"
anzq = text.count(suchq)
suchr = "r"
anzr = text.count(suchr)
suchs = "s"
anzs = text.count(suchs)
sucht = "t"
anzt = text.count(sucht)
suchu = "u"
anzu = text.count(suchu)
suchv = "v"
anzv = text.count(suchv)
suchw = "w"
anzw = text.count(suchw)
suchx = "x"
anzx = text.count(suchx)
suchy = "y"
anzy = text.count(suchy)
suchz = "z"
anzz = text.count(suchz)

#um das hier auszugeben über mehrere Zeilen also schön untereinander brauche ich eure hilfe

print(
"Der String", sucha, "kommt", anza, "mal vor.",
"Der String", suchb, "kommt", anzb, "mal vor.",
"Der String", suchc, "kommt", anzc, "mal vor.",
"Der String", suchd, "kommt", anzd, "mal vor.",
"Der String", suche, "kommt", anze, "mal vor.",
"Der String", suchf, "kommt", anzf, "mal vor.",
"Der String", suchg, "kommt", anzg, "mal vor.",
"Der String", suchh, "kommt", anzh, "mal vor.",
"Der String", suchi, "kommt", anzi, "mal vor.",
"Der String", suchj, "kommt", anzj, "mal vor.",
"Der String", suchk, "kommt", anzk, "mal vor.",
"Der String", suchl, "kommt", anzl, "mal vor.",
"Der String", suchm, "kommt", anzm, "mal vor.",
"Der String", suchn, "kommt", anzn, "mal vor.",
"Der String", sucho, "kommt", anzo, "mal vor.",
"Der String", suchp, "kommt", anzp, "mal vor.",
"Der String", suchq, "kommt", anzq, "mal vor.",
"Der String", suchr, "kommt", anzr, "mal vor.",
"Der String", suchs, "kommt", anzs, "mal vor.",
"Der String", sucht, "kommt", anzt, "mal vor.",
"Der String", suchu, "kommt", anzu, "mal vor.",
"Der String", suchv, "kommt", anzv, "mal vor.",
"Der String", suchw, "kommt", anzw, "mal vor.",
"Der String", suchx, "kommt", anzx, "mal vor.",
"Der String", suchy, "kommt", anzy, "mal vor.",
"Der String", suchz, "kommt", anzz, "mal vor.")

input()

# Ende

wenn ihr fragen habt wegen unübersichtlich oder so, fragt!!

danke!!!!!!


LG
Luap12

Re: Ausgabe über mehrere Zeilen

Verfasst: Dienstag 27. Juli 2010, 11:06
von cofi
Luap12 hat geschrieben:wieso?? meinst du ich hatte keine Lust das alles zu lesen!? gestern abend nicht mehr, das stimmt, aber heute morgen habe ich es schon versucht!!
Nein, weil in dem Snippet nur ein deutsches Wort aufgetaucht ist.

Code: Alles auswählen

import string
text = input("Bitte geben sie einen Text ein.")
laenge = len(text)

print("Anzahl der Zeichen im Text:", laenge)

for char in string.ascii_lowercase:
    print("%s kommt %d-mal in %s vor" % (char, text.count(char), text))