How to Change Capitalization of a String in Python


This example is to change the capitalization of a string using Python.

Source Code

#! /usr/bin/env python3
# -*- coding: utf-8 -*-

fp = open('D:/DESKTOP/7disktop/TEST/t1.txt','w')

string = input('Please input a string:n')

string = string.upper()

fp.write(string)

fp = open('D:/DESKTOP/7disktop/TEST/t1.txt','r')

print('The output of a string from the file:')

print(fp.read())

fp.close()

Output:

Please input a string:
dfekgaouty
String output from the file:
DFEKGAOUTY
Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments