# Infix to Postfix conversion using stack in Python?

**URL:** <https://forum.kirupa.com/t/infix-to-postfix-conversion-using-stack-in-python/667361>\
**Category:** programming\
**Created:** [June 6, 2024, 1:51am UTC](https://forum.kirupa.com/t/infix-to-postfix-conversion-using-stack-in-python/667361 "2024-06-06T01:51:07Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![oslon](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/oslon/32/24631_2.png) [@oslon](https://forum.kirupa.com/u/oslon)\
**Post date:** [June 6, 2024, 1:51am UTC](https://forum.kirupa.com/t/infix-to-postfix-conversion-using-stack-in-python/667361/1 "2024-06-06T01:51:08Z")

</div>

I’ve learnt the concept of infix to postfix and now I can do by hand infix to postfix conversion. Now, I want to write code in Python for it.

First I need to know, how do I read values from left to right in Python?

Then, I need to know, how to check if the string is left paranthesis, operand, operator or right paranthesis in Python. Other than that, I can write it.

---

<div class="post-metadata">

**Author:** ![kirupa](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/kirupa/32/11616_2.png) [@kirupa](https://forum.kirupa.com/u/kirupa)\
**Post date:** [June 6, 2024, 2:40am UTC](https://forum.kirupa.com/t/infix-to-postfix-conversion-using-stack-in-python/667361/2 "2024-06-06T02:40:53Z")

</div>

When you say “read values”, are you asking about how to read characters from a string?

---

<div class="post-metadata">

**Author:** ![oslon](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/oslon/32/24631_2.png) [@oslon](https://forum.kirupa.com/u/oslon)\
**Post date:** [June 6, 2024, 3:05am UTC](https://forum.kirupa.com/t/infix-to-postfix-conversion-using-stack-in-python/667361/3 "2024-06-06T03:05:41Z")

</div>

yea.

---

<div class="post-metadata">

**Author:** ![kirupa](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/kirupa/32/11616_2.png) [@kirupa](https://forum.kirupa.com/u/kirupa)\
**Post date:** [June 6, 2024, 3:21am UTC](https://forum.kirupa.com/t/infix-to-postfix-conversion-using-stack-in-python/667361/4 "2024-06-06T03:21:18Z")

</div>

How familiar are you with Python? This article describes some operations that can help you out: [How to Parse a String in Python – Parsing Strings Explained](https://www.freecodecamp.org/news/how-to-parse-a-string-in-python/)

Once you read a value, you can then check if the value equals another character like “(” or “+” or equivalent to start building up your pattern matching logic.
