How to return to previous part of the program (Python)
I’m novice in python and got a problem in which I would appreciate some help. The problem in short:
- ask for a string
- check if all letter in a predefined list
- if any letter is not in the list then ask for a new string, otherwise go to next step
- ask for a second string
- check again whether the second string’s letters in the list
- if any letter is not in the list then start over with asking for a new FIRST string
basicly my main question is how to go back to a previous part of my program, and it would also help if someone would write me the base of this code. It start like this:
4 Answers 4
You have a couple of options, you could use iteration, or recursion. For this kind of problem I would go with iteration. If you don’t know what iteration and recursion are, and how they work in Python then you should use the links Kugel suggested.
Подскажите как в python вернуться на действие назад?
Как вернуться на строчку назад
begin write(‘Сколько было игр ‘); readln(hmp); for i1:= 0 to hmp do begin.
Как сделать ссылку ‘вернуться назад’?
Как присвоить путь для кнопки так, что бы она возвращала на предыдущую страницу — тоже самое, что.
Как вернуться назад и при этом перезагрузить страницу?
<a href="javascript:history.go(-1);">&laquo; Вернуться назад</a> Вопрос: Как сделать так, чтобы.
Как перейти на другую форму окна, и вернуться назад
С# Как перейти на другую форму окна , и назад вернуться (без диалоговых окон) Нужно перейти в.
КАК ОТМЕНИТЬ ДЕЙСТВИЕ В PYTHON
В Python можно отменить последние действия, используя конструкцию undo . Например, если вы случайно удалили строки кода, вы можете вернуть их обратно, воспользовавшись этой функцией.
Чтобы использовать undo , вы должны вызвать метод undo() объекта, к которому хотите его применить. Этот метод можно вызвать несколько раз, чтобы отменить несколько последних операций.
some_code = «. «some_code = some_code[:-1] # Удаление последнего символаsome_code = some_code[:-1] # Удаление еще одного символаsome_code = some_code[:-1] # Удаление третьего символаsome_code.undo() # Отмена удаления третьего символаsome_code.undo() # Отмена удаления еще одного символа
Этот код удаляет последние 3 символа строки some_code, а затем отменяет последние 2 действия, вернув строку к исходному состоянию.
Важно понимать, что undo работает только для объектов, которые поддерживают эту функцию. Некоторые встроенные типы, такие как числа и кортежи, не поддерживают undo . Если попытаться вызвать этот метод для объекта, который не поддерживает эту функцию, возникнет ошибка.

Python в .EXE ► КАК?
Python 15 советов/трюков по коду
9 Cтроки и операции над ними Python
Псевдо-вирус на python
12 Списки и операции над ними Python
ЖУТКИЙ ВИРУС В JPG КАРТИНКЕ. ЭТО КАК? — Как его удалить? Как от этого защититься? — UnderMind
PyCharm keyboard shortcuts
PyCharm has keyboard shortcuts for most of its commands related to editing, navigation, refactoring, debugging, and other tasks. Memorizing these hotkeys can help you stay more productive by keeping your hands on the keyboard.
All default shortcuts are configurable and you can also assign shortcuts to any action that does not have them by default.
If your keyboard does not have an English layout, PyCharm may not detect all the shortcuts correctly.
The following table lists some of the most useful shortcuts to learn:
Quickly find any file, action, class, symbol, tool window, or setting in PyCharm, in your project, and in the current Git repository.
Find a command and execute it, open a tool window, or search for a setting.
Quick-fixes for highlighted errors and warnings, intention actions for improving and optimizing your code.
Jump to the next or previous highlighted error.
Select a recently opened file from the list.
Increase or decrease the scope of selection according to specific code constructs.
Comment out a line or block of code.
Show all places where a code element is used across your project.
Choose the right keymap
To view the keymap configuration, open the Settings dialog Control+Alt+S and select Keymap .
Enable function keys and check for possible conflicts with global OS shortcuts.
Use a predefined keymap
PyCharm automatically suggests a predefined keymap based on your environment. Make sure that it matches the OS you are using or select the one that matches shortcuts from another IDE or editor you are used to (for example, Emacs).
When consulting this page and other pages in PyCharm documentation, you can see keyboard shortcuts for the keymap that you use in the IDE — choose it using the selector at the top of a page.
Install a keymap from a plugin
Besides the default set of keymaps, you can install keymaps from plugins (such as, keymaps for GNOME and KDE): open the Settings dialog Control+Alt+S , select Plugins , switch to the Marketplace tab and search for keymap .
Tune your keymap
You can modify a copy of any predefined keymap to assign your own shortcuts for commands that you use frequently.
Import custom keymap
If you have a customized keymap that you are used to, you can transfer it to your installation.
If your keymap stopped working after an update, it is likely that the keymap is not available by default in the new version of PyCharm. Find this keymap as a plugin and install it on the Plugins page as described inInstall plugins.
Print your keymap
If you prefer a hard copy, download the default PyCharm keymap reference and print it out as a card:
Learn shortcuts as you work
PyCharm provides several possibilities to learn shortcuts:
PyCharm includes a built-in IDE Features Trainer. It provides interactive training courses to help you learn how to do some common tasks, such as refactoring code, navigating through projects, debugging, and working with version control.
Make sure the IDE Features Trainer plugin is enabled in the Installed tab of the Plugins page in the IDE settings.
To open the Learn tool window and start your exercises, select View | Tool Windows | Learn or Help | Learn IDE Features from the main menu. The tool window lists the available tutorials.
Find Action lets you search for commands and settings across all menus and tools.
Press Control+Shift+A and start typing to get a list of suggested actions. Then select the necessary action and press Enter to execute it.

To add or change the shortcut for any action, press Alt+Enter when it is selected in the list.
Key Promoter X is a plugin that shows a popup notification with the corresponding keyboard shortcut whenever a command is executed using the mouse. It also suggests creating a shortcut for commands that are executed frequently.
If you are using one of the predefined keymaps, you can print the default keymap reference card and keep it on your desk to consult it if necessary. This cheat sheet is also available under Help | Keyboard Shortcuts PDF .
To print a non-default or customized keymap, use the Keymap exporter plugin.
Use advanced features
You can further improve your productivity with the following useful features:
If there is a group of actions that you often use, create a quick list to access them using a custom shortcut. For example, you can try using the following predefined quick lists:
Refactor this Control+Alt+Shift+T
VCS Operations Alt+`
PyCharm provides a lot of typing assistance features , such as automatically adding paired tags and quotes, and detecting CamelHump words.
When the focus is on a tool window with a tree, list, or table, start typing to see matching items.
Some actions in PyCharm provide more results when you execute them multiple times. For example, when you invoke basic code completion with Control+Space on a part of a field, parameter, or variable declaration, it suggests names depending on the item type within the current scope. If you invoke it again, it will include classes available through module dependencies. When invoked for the third time in a row, the list of suggestions will include the whole project.
Resize tool windows
You can adjust the size of tool windows without a mouse:
To resize a vertical tool window, press Control+Alt+Shift+ArrowLeft and Control+Alt+Shift+ArrowRight
To resize a horizontal tool window, press Control+Alt+Shift+ArrowUp and Control+Alt+Shift+ArrowDown