Форум сайта python.su
0
Я только начал осваивать пайтон , помогите пожалуйста как перевести этот код в пайтоновский? До этого был знаком чуть-чуть только с С++
/* using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace pacman { class Program { static void Main(string[] args) { } } } */ using System; using System.Threading; namespace ConsolePacman { class Program { static void Main(string[] args) { const string EdibleKeyword = "асель"; //Ключевое слово string pacman = ">0"; while (true) { string input = Console.ReadLine(); if (input.EndsWith(EdibleKeyword)) { for (int i = input.Length - 1; i >= 0; i--) { Thread.Sleep(250); //250мс на каждую букву Console.Clear(); Console.WriteLine(input.Remove(i) + pacman); pacman = pacman == ">0" ? "=0" : ">0"; } Console.Clear(); } } } } }
for (int i = input.Length - 1; i >= 0; i--)
Отредактировано vik24rus (Апрель 8, 2012 13:53:07)
Офлайн
25
import sys import time EdibleKeyword = 'test' pacman = '>0' while True: my_input = raw_input().strip() if my_input.endswith(EdibleKeyword): for i in xrange(len(my_input)-1, -1, -1): print my_input[:i] + pacman pacman = '=0' if pacman == '>0' else '>0' time.sleep(1)
Офлайн
0
СПАСИБО!!!
нашел,можно еще так
while source: time.sleep(0.25) print source + ">0" time.sleep(0.25) source = source[:-1] print source + "=0"
import time EdibleKeyword = 'ce' source = raw_input() if source.endswith(EdibleKeyword): x = 0 while x < len(source): print source + ">0" source = source[0:len(source)-1] time.sleep(0.25) print source + "=0" time.sleep(0.25) else: print 'Error. Try again.'
Офлайн