Friday, June 5, 2020

Python tips

python tips:

In [1]: os.listdir(os.getcwd())==os.listdir(os.curdir)

Out[1]: True

In [2]: os.listdir(os.getcwd())==os.listdir('.')

Out[2]: True     


*******
WAP for print a character its position times in a word.

word=raw_input("Enter the word:")
for i in word:
    print i*word.index(i)

Output:

******
WAP for print a character its ASCII values times in a word.

word=raw_input("Enter the word:")
for i in word:
print i*ord(i)
#alternatively # print [i*ord(i) for i in word]

1 comment:

Apache Airflow notes