Python :: Aufgabe #19 :: Lösung #5
9 Lösungen

#19
Text nach Wörtern untersuchen
Anfänger - Python
von Dome
- 29.12.2012 um 01:37 Uhr
Ein Text und das Wort was gesucht werden soll, soll eingegeben werden. Daraufhin soll ausgegeben wie oft das Wort in dem Text vorhanden ist.
Konsolenausgabe:
Eingabe Text: Das ist mein Beispieltext.
Welches Wort soll gesucht werden: ist
Das Wort "ist" wurde 1 mal gefunden.
#5

von Nachbar (2820 Punkte)
- 19.10.2016 um 22:20 Uhr

# -*- coding: utf-8 -*- text = raw_input("Texteingabe: ").upper() wort = raw_input("\nGesuchtes Wort: ").upper() anzahl = 0 for i in text.split(): if i == wort: anzahl = anzahl + 1 print "\n\"" + wort + "\" kommt " + str(anzahl) + " mal im Text vor."
Kommentare:
Für diese Lösung gibt es noch keinen Kommentar
Seite 1 von 0
1