-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwebsite_rating2.py
More file actions
30 lines (21 loc) · 1.19 KB
/
Copy pathwebsite_rating2.py
File metadata and controls
30 lines (21 loc) · 1.19 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# This Python code creates a dictionary called websiteInfo with keys "name," "url," "description," and "rating," each initially set to None. The code then prompts the user to input relevant values for each key using a for loop that iterates over the keys. The input values are assigned to the corresponding keys in the dictionary.
# After gathering user input, the code prints the entered values for each key in the websiteInfo dictionary using another for loop that iterates over the dictionary's items. The output displays the keys and their associated values.
def get_user_input():
websiteInfo = {"name": None, "url": None, "description": None, "rating": None}
for name in websiteInfo.keys():
websiteInfo[name] = input(f"Enter relevant values for {name}: ")
print()
for name, value in websiteInfo.items():
print(f"{name}: {value}")
return websiteInfo
def main():
while True:
websiteInfo = get_user_input()
startOver = input("\nWould you like to start over? (y/n): ").lower()
if startOver == "y":
continue # Restart the loop
else:
print("Thank you for using the program!")
break # Exit the loop
if __name__ == "__main__":
main()