Найти - Пользователи
Полная версия: Буквы и/или числа в строке
Начало » Python для новичков » Буквы и/или числа в строке
1 2 3 4 5 6
qweqwe
x="Z15x33A2"
i=0
k=''
l=''
res=''
while i<=len(x):
try:
if int(x[i]):
k+=x[i]
res=l*int(k)
except:
print res,
k=''
try:
l=x[i]
except IndexError: pass


i+=1
Ed
хех :(
k = l = res = ''
for c in x:
if c.isdigit():
k += c
else:
if l and k:
res += l * int(k)
k = ''
l = c
print res + l * int(k)
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Powered by DjangoBB