Latest web development tutorials

Python incluye ejercicios 96

Python 100 Li Python 100 Li

Tema: contar el número de neutrones aparece cadena de cadena.

Análisis del programa: Ninguno.

Código fuente:

#!/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

La salida del ejemplo anterior es:

input a string:
www.w3big.com
input a sub string:
w3big
1

Python 100 Li Python 100 Li