Python beinhaltet 96 Übungen
Thema: zählen die Anzahl der Neutronen string erscheint.
Programmanalyse: Keine.
Source Code:
#!/usr/bin/python # -*- coding: UTF-8 -*- if __name__ == '__main__': str1 = raw_input('input a string:\n') str2 = raw_input('input a sub string:\n') ncount = str1.count(str2) print ncount
Das obige Beispiel Ausgabe lautet:
input a string: www.w3big.com input a sub string: w3big 1