wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
<?php
// code
?> | <?php
// code
?> | Correct. | PHP |
.User {{ color: #333; }} | .User {{ color: #333; }} | Correct. | CSS |
if (b = 64) {} | if (b == 64) {} | Use ==. | Dart |
let z = 27; let z = 14; | let z = 27; z = 14; | Duplicate declaration. | JavaScript |
$x = 5; echo $x | $x = 5; echo $x; | Missing semicolon. | PHP |
num = 57 | num=57 | No spaces. | Shell |
int* user = nullptr; *user=5; | int* user = new int; *user=5; | Allocate memory. | C++ |
if [ $b = 32 ]; then | if [ "$b" = 32 ]; then | Quote variable. | Shell |
let a = 77; a += 1; | let mut a = 77; a += 1; | Need mut to modify. | Rust |
with open('config.json') as fp:
data = fp.read() | with open('config.json') as fp:
data = fp.read() | Correct. | Python |
// comment | /* comment */ | Use /* */. | CSS |
for (y in list) | for (y of list) | for...in iterates keys. | JavaScript |
Write-Host 'data' | Write-Host 'data' | Correct. | PowerShell |
cin >> index; | int index;
cin >> index; | Declare variable. | C++ |
println('message') | println("message") | Double quotes. | Scala |
if ($b = 87) | if ($b == 87) | Use ==. | Perl |
yield a | yield a | Correct yield. | Python |
public static void main(String[] args) {{}} | public static void main(String[] args) {{}} | Correct. | Java |
[49, 70, 89 | [49, 70, 89] | Close bracket. | Python |
[x*x for x in arr if x > 76] | [x*x for x in arr if x > 76] | Correct list comprehension. | Python |
int[] arr = new int[30];
arr[30] = 5; | int[] arr = new int[30];
if (30 < arr.length) arr[30] = 5; | Check bounds. | Java |
else
print('world') | else:
print('world') | Colon after else. | Python |
int &ref; | int x; int &ref = x; | Reference must be initialized. | C++ |
if (bar = 54) | if (bar == 54) | Use ==. | R |
<table><tr><td>data<td>hello</tr></table> | <table><tr><td>data</td><td>hello</td></tr></table> | Close td. | HTML |
class Order {{ int y; }}
obj.y=5; | class Order {{ public int y; }}
obj.y=5; | Make field public. | Java |
const result; | const result = 28; | Initialize const. | JavaScript |
function compute(x:string){{return x;}} compute(58); | function compute(x:string){{return x;}} compute('hello'); | Pass correct type. | TypeScript |
while bar > 98
bar -= 1 | while bar > 98:
bar -= 1 | Colon missing after while. | Python |
class = 'message' | class_name = 'message' | 'class' is a keyword. | Python |
for i=1,20 do print(i) end | for i=1,20 do print(i) end | Correct. | Lua |
var item int = 'test' | var item string = 'test' | Type mismatch. | Go |
class Child Model: | class Child(Model): | Inheritance uses parentheses. | Python |
{{'id':'output'}} | {{"id":"output"}} | Use double quotes. | JSON |
<hr></hr> | <hr> | Self-closing. | HTML |
WHERE id = '28' | WHERE id = 28 | Don't quote integer. | SQL |
echo 'result' | echo 'result'; | Add semicolon. | PHP |
<div color=green> | <div style='color:green;'> | Use style attribute. | CSS |
h1 {{ font-size:1px color:#fff; }} | h1 {{ font-size:1px; color:#fff; }} | Add semicolon. | CSS |
data = value | data = 'value' | Quote strings. | Python |
val index: Int = 'data' | val index: String = 'data' | Fix type. | Kotlin |
DELETE FROM items WHERE age=81 | DELETE FROM items WHERE age=81; | Add semicolon. | SQL |
fmt.Println 'test' | fmt.Println('test') | Missing parentheses. | Go |
if (temp = 30) | if (temp == 30) | Use ==. | Scala |
list:
- item1
- item2 | list:
- item1
- item2 | Correct. | YAML |
fn process() -> i32 {{ 5 }} | fn process() -> i32 {{ 5 }} | Correct. | Rust |
<person name='test'/> | <person name="test"/> | Double quotes. | XML |
while read line; do echo $line; done < data.txt | while read line; do echo $line; done < data.txt | Correct. | Shell |
$x = 5; print $x | $x = 5; print $x; | Missing semicolon. | Perl |
if (a = 57) {{}} | if (a == 57) {{}} | Use ==. | Kotlin |
<person age=32> | <person age="32"> | Quote attribute. | XML |
for i in $(ls); do echo $i; done | for i in $(ls); do echo $i; done | Correct. | Shell |
<ul><li>data<li>hello</ul> | <ul><li>data</li><li>hello</li></ul> | Close li. | HTML |
$items[25] | if ($items.Count -gt 25) {{ $items[25] }} | Check bounds. | PowerShell |
JOIN orders ON orders.id = orders.name | JOIN orders ON orders.id = orders.name | Correct. | SQL |
@media screen {{ body {{}} }} | @media screen {{ body {{}} }} | Correct. | CSS |
var x = 5; x = true | var x = 5; x = 10 | Type mismatch. | Kotlin |
z == '21' | z === 21 | Use strict equality. | JavaScript |
SELECT id status FROM products; | SELECT id, status FROM products; | Add comma. | SQL |
if (item) console.log('yes') else console.log('no') | if (item) console.log('yes'); else console.log('no'); | Missing semicolon. | JavaScript |
let val = 'data' | let val = "data" | Double quotes. | Swift |
String name = 'result'; | String name = 'result'; | Correct. | Dart |
my @arr = (69,29,32); | my @arr = (69,29,32); | Correct. | Perl |
print 'result' | print('result') | print needs parentheses. | Python |
print 'result' | print 'result'; | Add semicolon. | Perl |
const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('data')); app.listen(92); | const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('data')); app.listen(92, () => console.log('listening')); | Add callback. | Node.js |
p {{ color: blue }} | p {{ color: blue; }} | Add semicolon. | CSS |
if data > 53
print('test') | if data > 53:
print('test') | Colon missing after if. | Python |
[70, 90, 66 | [70, 90, 66] | Close bracket. | Ruby |
if y = 71: | if y == 71: | Use == for comparison. | Python |
int main() {{ return 0; }} | int main() {{ return 0; }} | Correct. | C++ |
if data > 34
puts 'hello' | if data > 34
puts 'hello'
end | Add 'end'. | Ruby |
console.log('world' | console.log('world') | Close parenthesis. | JavaScript |
let msg = String::from("world"); let borrow=&msg; msg.push_str("!"); | let mut msg = String::from("world"); let borrow=&msg; println!("{{}}", borrow); msg.push_str("!"); | Cannot mutate while borrowed. | Rust |
if (result = 91) {{}} | if (result == 91) {{}} | Use ==. | Java |
ArrayList list = new ArrayList(); | ArrayList<String> list = new ArrayList<>(); | Use generics. | Java |
var x = 14; | var x = 14; | Correct. | Dart |
data[63] | if (length(data) >= 63) data[63] | Check length. | R |
values[17] | if values.indices.contains(17) {{ values[17] }} | Check index. | Swift |
<center>message</center> | <div style='text-align:center;'>message</div> | Use CSS. | HTML |
object Item {{ def main(args: Array[String]) = println("message") }} | object Item {{ def main(args: Array[String]): Unit = println("message") }} | Add return type Unit. | Scala |
const http = require('http'); http.createServer((req,res) => res.end('data')).listen(22); | const http = require('http'); http.createServer((req,res) => res.end('data')).listen(22); | Correct. | Node.js |
if (data = 3) {{}} | if (data === 3) {{}} | Use === for equality. | JavaScript |
const user:Person = {{name:'hello'}}; | const user:Person = {{name:'hello', age:20}}; | Add missing property. | TypeScript |
List(83,84,61) | List(83,84,61) | Correct. | Scala |
echo test test | echo 'test test' | Quote to prevent splitting. | Shell |
function render(): void {{ return 46; }} | function render(): number {{ return 46; }} | Return type mismatch. | TypeScript |
let data: i32 = "hello"; | let data: &str = "hello"; | Type mismatch. | Rust |
function baz() {{
return
{{key:'info'}}
}} | function baz() {{
return {{key:'info'}};
}} | Return object on same line. | JavaScript |
print('data') | print('data') | Correct. | R |
cin >> a
cout << a; | cin >> a;
cout << a; | Add semicolon. | C++ |
if data = 26 | if data == 26 | Use ==. | Go |
'74' + 90 | 74 + 90 | Avoid string coercion. | JavaScript |
["result", 76] | ["result", 76] | Correct. | JSON |
{{'status':60, 'id' 62}} | {{'status':60, 'id':62}} | Colon missing. | Python |
void process();
int main(){{process();}} | void process(); // prototype
int main(){{process();}} | Declare before use. | C++ |
x := 5 | x := 5 | Correct. | Go |
match foo {{ 1 => {{}} }} | match foo {{ 1 => {{}} _ => {{}} }} | Match must be exhaustive. | Rust |
def render(bar):
return bar + 1 | def render(bar):
return bar + 1 | Correct. | Python |
int item = 'result'; | String item = 'result'; | Type mismatch. | Dart |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.