To Underline Text In Python, the Unicode character
"\u0332" acts as an underline on the character that precedes it in a string. So, if you put any string after this Unicode, the text will be printed underlined in Python.
Underline Text In Python using
def underline(text): print("\u0332".join(text)) print("\u0332".join("How are you?")) underline("Hello reader!")
H̲e̲l̲l̲o̲ ̲r̲e̲a̲d̲e̲r̲! H̲o̲w̲ ̲a̲r̲e̲ ̲y̲o̲u̲?
You can try the ANSI escape sequences method as well to Underline Text In Python from this answer on StackOverflow.
class Format: end = '\033[0m' underline = '\033[4m' print(Format.underline + 'Your text here' + Format.end)
Your text here
We hope these examples will help you to learn how to print underlined text in Python.
Thank you for reading this article, click here to start learning Python in 2022.
- SQLite | CRUD Operations in Python
- Event Management System Project in Python
- Ticket Booking and Management in Python
- Hostel Management System Project in Python
- Sales Management System Project in Python
- Bank Management System Project in C++
- Python Download File from URL | 4 Methods
- Python Programming Examples | Fundamental Programs in Python
- Spell Checker in Python
- Portfolio Management System in Python
- Stickman Game in Python
- Contact Book project in Python
- Loan Management System Project in Python
- Cab Booking System in Python
- Brick Breaker Game in Python
- 100+ Java Projects for Beginners 2023
- Tank game in Python
- GUI Piano in Python
- Ludo Game in Python
- Rock Paper Scissors Game in Python
- Snake and Ladder Game in Python
- Puzzle Game in Python
- Medical Store Management System Project in Python
- Creating Dino Game in Python
- Tic Tac Toe Game in Python
- Courier Tracking System in HTML CSS and JS
- Test Typing Speed using Python App
- Scientific Calculator in Python
- GUI To-Do List App in Python Tkinter
- Scientific Calculator in Python using Tkinter