Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

finding-the-largest-three-digits-number-within-a-number

#!/usr/bin/env python

num = input("Enter the number : ")

if len(num) == 3:
    print(f"Largest digit is : {num}")
    exit(0)
elif len(num) < 3:
    print(-1)
    exit(0)

maxans = int((num[0].replace("0", "")))*100 + int((num[1].replace("0", "")))*10 + int((num[2].replace("0", "")))
prev = maxans

for i in range(3, 6):
    cur = (prev%100)*10 + int((num[i].replace("0", "")))
    maxans = max(maxans, cur)
    prev = cur

print(f"The Largest num = : {maxans}")
Comment

PREVIOUS NEXT
Code Example
Python :: rasa emotion bot 
Python :: combination in python without itertools 
Python :: python selectionsort 
Python :: qmenu 
Python :: tensorflow 1.x spp implementation 
Python :: Simple GUI 
Python :: operasi tipe data integer 
Python :: python re return index of match 
Python :: block-all-mixed-content csp bypass python 
Python :: update table odoo13 
Python :: how to show type of a variable 
Python :: SQLAlchemy ordering by count on a many to many relationship 
Python :: session timeout flask 
Python :: extracting code blocks from Markdown 
Python :: python static 
Python :: list foreach pyhton 
Python :: ring write the key and the IV directly using strings 
Python :: word cloud mape python 
Python :: python dict setdefault list 
Python :: size of variable 
Python :: tkinter trig calculator 
Python :: Python 2.7 to 3.x Linux 
Python :: attribute error rest framework 
Python :: fibonacci numbers in lamda python 
Python :: rolingmean python 
Python :: jupyter notebook save as python script without terminal prompts line numbers 
Python :: convert json file to dict - if comming as list 
Python :: @action(detail=true) meaning 
Python :: pyplot common labels 
Python :: Select a Column in pandas data Frame Using dot notation 
ADD CONTENT
Topic
Content
Source link
Name
3+5 =