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!!^^
Ausgabe über mehrere Zeilen
Code: Alles auswählen
>>> greet = """\
... Hallo,
... {name}
... !!!""".format(name='snafu')
>>> print(greet)
Hallo,
snafu
!!!
- cofi
- Python-Forum Veteran
- Beiträge: 4432
- Registriert: Sonntag 30. März 2008, 04:16
- Wohnort: RGFybXN0YWR0
Deutsch hat wohl nicht den Ausschlag gegeben
Michael Markert ❖ PEP 8 Übersetzung ❖ Tutorial Übersetzung (3.x) ⇒ Online-Version (Python 3.3) ❖ Deutscher Python-Insider ❖ Projekte
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!!cofi hat geschrieben:Deutsch hat wohl nicht den Ausschlag gegeben
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
- cofi
- Python-Forum Veteran
- Beiträge: 4432
- Registriert: Sonntag 30. März 2008, 04:16
- Wohnort: RGFybXN0YWR0
Nein, weil in dem Snippet nur ein deutsches Wort aufgetaucht ist.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!!
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))
Michael Markert ❖ PEP 8 Übersetzung ❖ Tutorial Übersetzung (3.x) ⇒ Online-Version (Python 3.3) ❖ Deutscher Python-Insider ❖ Projekte