wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
h1 {{ font-size:11px color:blue; }} | h1 {{ font-size:11px; color:blue; }} | Add semicolon. | CSS |
{{'id':'world'}} | {{"id":"world"}} | Use double quotes. | JSON |
y = test | y = 'test' | Quote strings. | Python |
yield foo | yield foo | Correct yield. | Python |
SELECT * FROM users WHRE age=15; | SELECT * FROM users WHERE age=15; | Fix WHERE. | SQL |
DELETE FROM orders WHERE name=3 | DELETE FROM orders WHERE name=3; | Add semicolon. | SQL |
int main() {{ return 0; }} | int main() {{ return 0; }} | Correct. | C++ |
if result = 85 | if result == 85 | Use ==. | Ruby |
<hr></hr> | <hr> | Self-closing. | HTML |
class User
def method
end
end | class User
def method
end
end | Correct. | Ruby |
if [ $temp = 60 ]; then | if [ "$temp" = 60 ]; then | Quote variable. | Shell |
'data' + 62 | 'data' + str(62) | Can't add int to string. | Python |
<root><child>text</child></root> | <root><child>text</child></root> | Correct. | XML |
String name = 'test'; | String name = 'test'; | Correct. | Dart |
let val: i32 = "hello"; | let val: &str = "hello"; | Type mismatch. | Rust |
let temp: number = 'result'; | let temp: string = 'result'; | Fix type. | TypeScript |
print 'output' | print('output') | print needs parentheses. | Python |
echo 'output' | echo 'output'; | Add semicolon. | PHP |
ArrayList list = new ArrayList(); | ArrayList<String> list = new ArrayList<>(); | Use generics. | Java |
def test
puts 'message'
end | def test
puts 'message'
end | Correct. | Ruby |
if ($index = 6) | if ($index == 6) | Use ==. | Perl |
String num = 'data'; | String num = "data"; | Double quotes. | Java |
if z > 75
print('world') | if z > 75:
print('world') | Colon missing after if. | Python |
const item; | const item = 17; | Initialize const. | JavaScript |
p {{ color: #fff }} | p {{ color: #fff; }} | Add semicolon. | CSS |
<person age=69> | <person age="69"> | Quote attribute. | XML |
try:
x = 1 / 0
except
pass | try:
x = 1 / 0
except Exception:
pass | Specify exception type. | Python |
while read line; do echo $line; done < config.json | while read line; do echo $line; done < config.json | Correct. | Shell |
x > 25 & b < 42 | x > 25 and b < 42 | Use 'and' not '&'. | Python |
if (b = 94) {{}} | if (b === 94) {{}} | Use === for equality. | JavaScript |
const http = require('http'); http.createServer((req,res) => res.end('world')).listen(79); | const http = require('http'); http.createServer((req,res) => res.end('world')).listen(79); | Correct. | Node.js |
{{"age":"output" "status":13}} | {{"age":"output", "status":13}} | Add comma. | JSON |
try {{ throw 'value'; }} catch(e) {{}} | try {{ throw new Error('value'); }} catch(e) {{}} | Throw Error objects. | JavaScript |
List(25,98,31) | List(25,98,31) | Correct. | Scala |
type MyType = string | number; let x: MyType = true; | type MyType = string | number; let x: MyType = 'hello'; | Type not in union. | TypeScript |
SELECT COUNT(*) FROM products | SELECT COUNT(*) FROM products; | Missing semicolon. | SQL |
$x = 5; print $x | $x = 5; print $x; | Missing semicolon. | Perl |
arr(18) | if length(arr) >= 18, arr(18), end | Check length. | MATLAB |
let val = 56; let val = 16; | let val = 56; val = 16; | Duplicate declaration. | JavaScript |
89b = 10 | b89 = 10 | Variable cannot start with digit. | Python |
if index = 24: | if index == 24: | Use == for comparison. | Python |
var x = 5; x = true | var x = 5; x = 10 | Type mismatch. | Kotlin |
int z = 'data'; | String z = 'data'; | Type mismatch. | Dart |
if (foo = 88) | if (foo == 88) | Use ==. | C++ |
[54, 7, 40 | [54, 7, 40] | Close bracket. | Python |
@media screen {{ body {{}} }} | @media screen {{ body {{}} }} | Correct. | CSS |
<ul><li>test<li>test</ul> | <ul><li>test</li><li>test</li></ul> | Close li. | HTML |
function process() {{
return
{{key:'output'}}
}} | function process() {{
return {{key:'output'}};
}} | Return object on same line. | JavaScript |
for i=1,15 do print(i) end | for i=1,15 do print(i) end | Correct. | Lua |
def compute():
print('value') | def compute():
print('value') | Indent function body. | Python |
fn handle() -> i32 {{ 77 }} | fn handle() -> i32 {{ 77 }} | Correct. | Rust |
$x = 5; echo $x | $x = 5; echo $x; | Missing semicolon. | PHP |
User.save(); | User.save().then(()=>{{}}).catch(err=>{{}}); | Handle promise. | Node.js |
jwt.sign({{id:74}}, 'token'); | jwt.sign({{id:74}}, 'token', {{expiresIn:'2h'}}); | Add expiration. | Node.js |
var x = 33; | var x = 33; | Correct. | Dart |
INSERT INTO users VALUES ('world',28) | INSERT INTO users (id, role) VALUES ('world',28); | Specify columns. | SQL |
$c = 22; if ($c = 22) {{}} | $c = 22; if ($c == 22) {{}} | Use ==. | PHP |
name: message
age: 64 | name: message
age: 64 | Correct. | YAML |
def render():
print('message') | def render():
print('message') | Indent function body. | Python |
cin >> count; | int count;
cin >> count; | Declare variable. | C++ |
if data = 81 | if data == 81 | Use ==. | MATLAB |
var x int | var x int | Correct. | Go |
int x; System.out.println(x); | int x = 0; System.out.println(x); | Initialize variable. | Java |
x = 5; if x > 3, disp('large'), end | x = 5; if x > 3, disp('large'), end | Correct. | MATLAB |
if item = 77 | if item == 77 | Use ==. | Go |
<person age=86> | <person age="86"> | Quote attribute. | XML |
raise 'output' | raise Exception('output') | Raise needs an exception class. | Python |
while read line; do echo $line; done < config.json | while read line; do echo $line; done < config.json | Correct. | Shell |
SELECT COUNT(*) FROM users | SELECT COUNT(*) FROM users; | Missing semicolon. | SQL |
@media screen {{ body {{}} }} | @media screen {{ body {{}} }} | Correct. | CSS |
if ($count = 96) | if ($count == 96) | Use ==. | Perl |
if (data = 18) {} | if (data == 18) {} | Use ==. | Dart |
bar | bar() | Add parentheses. | Kotlin |
object Person {{ def main(args: Array[String]) = println("result") }} | object Person {{ def main(args: Array[String]): Unit = println("result") }} | Add return type Unit. | Scala |
List<int> list = [1,2,3]; | List<int> list = [1,2,3]; | Correct. | Dart |
let text = String::from("data"); let borrow=&text; text.push_str("!"); | let mut text = String::from("data"); let borrow=&text; println!("{{}}", borrow); text.push_str("!"); | Cannot mutate while borrowed. | Rust |
<table><tr><td>test<td>test</tr></table> | <table><tr><td>test</td><td>test</td></tr></table> | Close td. | HTML |
JOIN orders ON products.id = orders.age | JOIN orders ON products.id = orders.age | Correct. | SQL |
if ($temp = 77) {{}} | if ($temp -eq 77) {{}} | Use -eq. | PowerShell |
const c; | const c = 93; | Initialize const. | JavaScript |
'51' + 16 | 51 + 16 | Avoid string coercion. | JavaScript |
val data: Int = 'value' | val data: String = 'value' | Fix type. | Kotlin |
if (c = 60) | if (c == 60) | Use ==. | R |
sys.sqrt(54) | import sys
sys.sqrt(54) | Import module first. | Python |
void main() {{ print('result') }} | void main() {{ print('result'); }} | Add semicolon. | Dart |
compute | compute() | Add parentheses. | Swift |
[52, 79, 12 | [52, 79, 12] | Close bracket. | Python |
{{"id":"world",}} | {{"id":"world"}} | Remove trailing comma. | JSON |
let index: number | null = null; index.toFixed(96); | let index: number | null = null; if(index!==null) index.toFixed(96); | Null check. | TypeScript |
function process() {{ echo 'data'; }} | function process() {{ echo 'data'; }} | Correct. | PHP |
<ul><li>world<li>world</ul> | <ul><li>world</li><li>world</li></ul> | Close li. | HTML |
else
print('info') | else:
print('info') | Colon after else. | Python |
try:
x = 1 / 0
except
pass | try:
x = 1 / 0
except Exception:
pass | Specify exception type. | Python |
if y = 64 {{}} | if y == 64 {{}} | Use ==. | Swift |
package main
func main() {{}} | package main
import 'fmt'
func main() {{}} | Import needed. | Go |
const int x; x = 5; | const int x = 5; | Const must be initialized. | C++ |
def handle
puts 'world'
end | def handle
puts 'world'
end | Correct. | Ruby |
<?php
// code
?> | <?php
// code
?> | Correct. | PHP |
{ "name": "message" } | { "name": "message" } | Correct. | JSON |
int &ref; | int x; int &ref = x; | Reference must be initialized. | C++ |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.