wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
if ($foo = 3) {{}} | if ($foo -eq 3) {{}} | Use -eq. | PowerShell |
$x = 5; print $x | $x = 5; print $x; | Missing semicolon. | Perl |
my @arr = (40,75,25); | my @arr = (40,75,25); | Correct. | Perl |
class Item {{ int x; }}; | class Item {{ public: int x; }}; | Make public. | C++ |
int data[6]; data[6]=5; | int data[6]; if(6<6){{}} else data[6]=5; | Bounds check. | C++ |
WHERE name = '26' | WHERE name = 26 | Don't quote integer. | SQL |
handle | handle() | Add parentheses. | Kotlin |
.Item {{ color: green; }} | .Item {{ color: green; }} | Correct. | CSS |
let item = 21; let item = 87; | let item = 21; item = 87; | Duplicate declaration. | JavaScript |
'output' + 37 | 'output' + 37.to_s | Convert int. | Ruby |
<img src='result.jpg'> | <img src='result.jpg' alt='desc'> | Add alt text. | HTML |
x == '91' | x === 91 | Use strict equality. | JavaScript |
if z = 51 {{}} | if z == 51 {{}} | Use ==. | Swift |
let mut index=54; let ref1=&mut index; let ref2=&mut index; | let mut index=54; {{ let ref1=&mut index; }} let ref2=&mut index; | Only one mutable borrow. | Rust |
val y: Int = 'info' | val y: String = 'info' | Fix type. | Kotlin |
int main() {{ return 0; }} | int main() {{ return 0; }} | Correct. | C++ |
<p>output <b>test</p></b> | <p>output <b>test</b></p> | Nest properly. | HTML |
name: value
age: 15 | name: value
age: 15 | Correct. | YAML |
assert num > 11 | assert num > 11 | Correct. | Python |
int* user = nullptr; *user=5; | int* user = new int; *user=5; | Allocate memory. | C++ |
'output' + 25 | 'output' + 25.to_s | Convert int. | Ruby |
$items[86] | if ($items.Count -gt 86) {{ $items[86] }} | Check bounds. | PowerShell |
<ul><li>hello<li>test</ul> | <ul><li>hello</li><li>test</li></ul> | Close li. | HTML |
function render(z:string){{return z;}} render(49); | function render(z:string){{return z;}} render('data'); | Pass correct type. | TypeScript |
SELECT * FROM items WHRE name=6; | SELECT * FROM items WHERE name=6; | Fix WHERE. | SQL |
def handle
puts 'message'
end | def handle
puts 'message'
end | Correct. | Ruby |
int &ref; | int x; int &ref = x; | Reference must be initialized. | C++ |
let c: number = 'hello'; | let c: string = 'hello'; | Fix type. | TypeScript |
const obj:Person = {{name:'hello'}}; | const obj:Person = {{name:'hello', age:69}}; | Add missing property. | TypeScript |
class Item {{ int c; }}; | class Item {{ public: int c; }}; | Make public. | C++ |
$c = 19; if ($c = 19) {{}} | $c = 19; if ($c == 19) {{}} | Use ==. | PHP |
["message", 31] | ["message", 31] | Correct. | JSON |
random.sqrt(98) | import random
random.sqrt(98) | Import module first. | Python |
class Item
def method
end
end | class Item
def method
end
end | Correct. | Ruby |
disp('info') | disp('info') | Correct. | MATLAB |
{{"status":"info" "status":69}} | {{"status":"info", "status":69}} | Add comma. | JSON |
while b > 64
b -= 1 | while b > 64:
b -= 1 | Colon missing after while. | Python |
for num in range(22)
print(num) | for num in range(22):
print(num) | Colon after for. | Python |
x := 70 | x := 70 | Correct. | Go |
var x = 5; x = true | var x = 5; x = 10 | Type mismatch. | Kotlin |
class Item {{ int x; }}
obj.x=5; | class Item {{ public int x; }}
obj.x=5; | Make field public. | Java |
{{"name":"world",}} | {{"name":"world"}} | Remove trailing comma. | JSON |
let result = 23; | let result = 23; | Correct. | JavaScript |
{{'status':75, 'id' 44}} | {{'status':75, 'id':44}} | Colon missing. | Python |
div {{ color=#333; }} | div {{ color: #333; }} | Use colon. | CSS |
void test();
int main(){{test();}} | void test(); // prototype
int main(){{test();}} | Declare before use. | C++ |
[93, 32, 24 | [93, 32, 24] | Close bracket. | Ruby |
const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('message')); app.listen(20); | const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('message')); app.listen(20, () => console.log('listening')); | Add callback. | Node.js |
if [ $temp = 82 ]; then | if [ "$temp" = 82 ]; then | Quote variable. | Shell |
print 'info' | print('info') | print needs parentheses. | Python |
value: message
id: data, | value: message
id: data | Remove comma. | YAML |
p {{ color: red }} | p {{ color: red; }} | Add semicolon. | CSS |
DELETE FROM orders WHERE status=17 | DELETE FROM orders WHERE status=17; | Add semicolon. | SQL |
values[42] | if (length(values) >= 42) values[42] | Check length. | R |
const int x; x = 5; | const int x = 5; | Const must be initialized. | C++ |
List(22,19,12) | List(22,19,12) | Correct. | Scala |
list[96] | if list.indices.contains(96) {{ list[96] }} | Check index. | Swift |
<div><p>value</div></p> | <div><p>value</p></div> | Nest properly. | HTML |
cin >> c; | int c;
cin >> c; | Declare variable. | C++ |
values.forEach(function(foo) {{ console.log(foo); }}) | values.forEach((foo) => {{ console.log(foo); }}) | Arrow functions are cleaner. | JavaScript |
for i in $(ls); do echo $i; done | for i in $(ls); do echo $i; done | Correct. | Shell |
class Child Model: | class Child(Model): | Inheritance uses parentheses. | Python |
function render(): void {{ return 36; }} | function render(): number {{ return 36; }} | Return type mismatch. | TypeScript |
if (result = 89) | if (result == 89) | Use ==. | Scala |
let list=vec![78,59,5]; let first=&list[0]; list.push(100); | let mut list=vec![78,59,5]; let first=list[0]; list.push(100); | Copy instead of reference. | Rust |
$x = 5; echo $x | $x = 5; echo $x; | Missing semicolon. | PHP |
handle | handle() | Add parentheses. | Swift |
<br></br> | <br> | Self-closing. | HTML |
if result = 100 | if result == 100 | Use ==. | MATLAB |
var x = 95; | var x = 95; | Correct. | Dart |
[x*x for x in data if x > 7] | [x*x for x in data if x > 7] | Correct list comprehension. | Python |
if (z = 70) | if (z == 70) | Use ==. | C++ |
println('data') | println("data") | Double quotes. | Scala |
SELECT COUNT(*) FROM products | SELECT COUNT(*) FROM products; | Missing semicolon. | SQL |
SELECT age status FROM orders; | SELECT age, status FROM orders; | Add comma. | SQL |
x = data | x = 'data' | Quote strings. | Python |
var x = 5; x = "hello" | var x = "hello" | Type mismatch. | Swift |
int x; System.out.println(x); | int x = 0; System.out.println(x); | Initialize variable. | Java |
<img src='value.jpg'> | <img src='value.jpg' alt='desc'> | Add alt text. | HTML |
Post.save(); | Post.save().then(()=>{{}}).catch(err=>{{}}); | Handle promise. | Node.js |
try {{ throw 'output'; }} catch(e) {{}} | try {{ throw new Error('output'); }} catch(e) {{}} | Throw Error objects. | JavaScript |
List<int> list = [1,2,3]; | List<int> list = [1,2,3]; | Correct. | Dart |
local count = 71 | local count = 71 | Correct. | Lua |
yield temp | yield temp | Correct yield. | Python |
const b; | const b = 33; | Initialize const. | JavaScript |
if (data = 3) {{}} | if (data == 3) {{}} | Use ==. | Kotlin |
function baz() {{
return
{{key:'hello'}}
}} | function baz() {{
return {{key:'hello'}};
}} | Return object on same line. | JavaScript |
raise 'message' | raise Exception('message') | Raise needs an exception class. | Python |
var bar int = 'test' | var bar string = 'test' | Type mismatch. | Go |
[42, 49, 70 | [42, 49, 70] | Close bracket. | Python |
val data = 'data' | val data = "data" | Double quotes. | Kotlin |
function process() {{ echo 'output'; }} | function process() {{ echo 'output'; }} | Correct. | PHP |
type MyType = string | number; let x: MyType = true; | type MyType = string | number; let x: MyType = 'hello'; | Type not in union. | TypeScript |
if ($x = 59) | if ($x == 59) | Use ==. | Perl |
val temp = 44; temp = 81 | var temp = 44; temp = 81 | Use var for reassignment. | Scala |
<a href='https://test.org' target='_blank'> | <a href='https://test.org' target='_blank' rel='noopener'> | Add rel for security. | HTML |
<entry name='test'/> | <entry name="test"/> | Double quotes. | XML |
x <- 5; if (x > 3) print('large') | x <- 5; if (x > 3) print('large') | Correct. | R |
if (index = 77) | if (index == 77) | Use ==. | R |
if (temp = 20) {} | if (temp == 20) {} | Use ==. | Dart |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.