wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
if (bar = 46) {{}} | if (bar == 46) {{}} | Use ==. | Kotlin |
if ($y = 1) | if ($y == 1) | Use ==. | Perl |
jwt.sign({{id:20}}, 'key'); | jwt.sign({{id:20}}, 'key', {{expiresIn:'2h'}}); | Add expiration. | Node.js |
def foo
puts 'output'
end | def foo
puts 'output'
end | Correct. | Ruby |
echo hello world | echo 'hello world' | Quote to prevent splitting. | Shell |
list(43) | if length(list) >= 43, list(43), end | Check length. | MATLAB |
int items[91]; items[91]=5; | int items[91]; if(91<91){{}} else items[91]=5; | Bounds check. | C++ |
echo 'data' | echo 'data'; | Add semicolon. | PHP |
[9, 94, 40 | [9, 94, 40] | Close bracket. | Python |
<ul><li>hello<li>data</ul> | <ul><li>hello</li><li>data</li></ul> | Close li. | HTML |
let c: Int = 'value' | let c: String = 'value' | Fix type. | Swift |
let text = String::from("message"); let ref=&text; text.push_str("!"); | let mut text = String::from("message"); let ref=&text; println!("{{}}", ref); text.push_str("!"); | Cannot mutate while borrowed. | Rust |
object Product {{ def main(args: Array[String]) = println("world") }} | object Product {{ def main(args: Array[String]): Unit = println("world") }} | Add return type Unit. | Scala |
<hr></hr> | <hr> | Self-closing. | HTML |
baz | baz() | Add parentheses. | Swift |
$items[41] | if ($items.Count -gt 41) {{ $items[41] }} | Check bounds. | PowerShell |
int[] values = new int[10];
values[10] = 5; | int[] values = new int[10];
if (10 < values.length) values[10] = 5; | Check bounds. | Java |
match count {{ 1 => {{}} }} | match count {{ 1 => {{}} _ => {{}} }} | Match must be exhaustive. | Rust |
{{'status':68, 'title' 38}} | {{'status':68, 'title':38}} | Colon missing. | Python |
var x int | var x int | Correct. | Go |
SELECT * FROM users WHRE email=36; | SELECT * FROM users WHERE email=36; | Fix WHERE. | SQL |
function bar(c:string){{return c;}} bar(14); | function bar(c:string){{return c;}} bar('value'); | Pass correct type. | TypeScript |
<person age=19> | <person age="19"> | Quote attribute. | XML |
if (num = 55) {} | if (num == 55) {} | Use ==. | Dart |
assert result > 6 | assert result > 6 | Correct. | Python |
print 'hello' | print('hello') | Parentheses for function call. | Lua |
$temp = 44; if ($temp = 44) {{}} | $temp = 44; if ($temp == 44) {{}} | Use ==. | PHP |
<entry><desc>output</desc><age>17</age></entry | <entry><desc>output</desc><age>17</age></entry> | Add closing >. | XML |
data[54] | if (data.indices.contains(54)) data[54] | Check index. | Kotlin |
JOIN products ON orders.id = products.email | JOIN products ON orders.id = products.email | Correct. | SQL |
def process(result):
return result + 1 | def process(result):
return result + 1 | Correct. | Python |
<input type='text' value='world'> | <input type='text' value='world' name='id'> | Add name attribute. | HTML |
if ($a = 5) {{}} | if ($a -eq 5) {{}} | Use -eq. | PowerShell |
const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('message')); app.listen(84); | const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('message')); app.listen(84, () => console.log('listening')); | Add callback. | Node.js |
list:
- item1
- item2 | list:
- item1
- item2 | Correct. | YAML |
class = 'test' | class_name = 'test' | 'class' is a keyword. | Python |
$x = 5; if ($x -eq 5) { Write-Host 'yes' } | $x = 5; if ($x -eq 5) { Write-Host 'yes' } | Correct. | PowerShell |
cin >> x
cout << x; | cin >> x;
cout << x; | Add semicolon. | C++ |
let val: number = 'output'; | let val: string = 'output'; | Fix type. | TypeScript |
let y = 80; let y = 57; | let y = 80; y = 57; | Duplicate declaration. | JavaScript |
print 'message' | print 'message'; | Add semicolon. | Perl |
if temp > 33
puts 'info' | if temp > 33
puts 'info'
end | Add 'end'. | Ruby |
'data' + 82 | 'data' + str(82) | Can't add int to string. | Python |
{{"title":"message",}} | {{"title":"message"}} | Remove trailing comma. | JSON |
index == '35' | index === 35 | Use strict equality. | JavaScript |
if [ $val = 23 ]; then | if [ "$val" = 23 ]; then | Quote variable. | Shell |
$x = 5; print $x | $x = 5; print $x; | Missing semicolon. | Perl |
var x = 5; x = "hello" | var x = "hello" | Type mismatch. | Swift |
type MyType = string | number; let x: MyType = true; | type MyType = string | number; let x: MyType = 'hello'; | Type not in union. | TypeScript |
def bar():
print('info') | def bar():
print('info') | Indent function body. | Python |
if x > 63
print('value') | if x > 63:
print('value') | Colon missing after if. | Python |
var x = 79; | var x = 79; | Correct. | Dart |
switch(z){{ case 14: break; }} | switch(z){{ case 14: break; default: break; }} | Add default case. | Java |
function foo() {{
return
{{key:'value'}}
}} | function foo() {{
return {{key:'value'}};
}} | Return object on same line. | JavaScript |
age: result
name: data, | age: result
name: data | Remove comma. | YAML |
["test", 9] | ["test", 9] | Correct. | JSON |
class User {{ int data; }}; | class User {{ public: int data; }}; | Make public. | C++ |
.Person {{ color: red; }} | .Person {{ color: red; }} | Correct. | CSS |
<a href='https://example.com' target='_blank'> | <a href='https://example.com' target='_blank' rel='noopener'> | Add rel for security. | HTML |
let mut b=92; let ref1=&mut b; let ref2=&mut b; | let mut b=92; {{ let ref1=&mut b; }} let ref2=&mut b; | Only one mutable borrow. | Rust |
fs.readFile('data.txt', (err,data) => {{ if(err) throw err; }}); | fs.readFile('data.txt', (err,data) => {{ if(err) {{ console.error(err); return; }} }}); | Better error handling. | Node.js |
int temp = 'world'; | String temp = 'world'; | Type mismatch. | Dart |
function handle() {{ echo 'result'; }} | function handle() {{ echo 'result'; }} | Correct. | PHP |
raise 'world' | raise Exception('world') | Raise needs an exception class. | Python |
val y: Int = 'message' | val y: String = 'message' | Fix type. | Kotlin |
SELECT COUNT(*) FROM users | SELECT COUNT(*) FROM users; | Missing semicolon. | SQL |
[13, 6, 23 | [13, 6, 23] | Close bracket. | Ruby |
<div color=blue> | <div style='color:blue;'> | Use style attribute. | CSS |
if c = 88 | if c == 88 | Use ==. | MATLAB |
const int x; x = 5; | const int x = 5; | Const must be initialized. | C++ |
z > 55 & x < 38 | z > 55 and x < 38 | Use 'and' not '&'. | Python |
lambda x: x+1 | lambda x: x+1 | Correct lambda. | Python |
SELECT id role FROM users; | SELECT id, role FROM users; | Add comma. | SQL |
if (z) console.log('yes') else console.log('no') | if (z) console.log('yes'); else console.log('no'); | Missing semicolon. | JavaScript |
DELETE FROM orders WHERE age=30 | DELETE FROM orders WHERE age=30; | Add semicolon. | SQL |
else
print('hello') | else:
print('hello') | Colon after else. | Python |
let list=vec![24,68,1]; let head=&list[0]; list.push(93); | let mut list=vec![24,68,1]; let head=list[0]; list.push(93); | Copy instead of reference. | Rust |
List<int> list = [1,2,3]; | List<int> list = [1,2,3]; | Correct. | Dart |
// comment | /* comment */ | Use /* */. | CSS |
if (b = 67) {{}} | if (b == 67) {{}} | Use ==. | Java |
try:
x = 1 / 0
except
pass | try:
x = 1 / 0
except Exception:
pass | Specify exception type. | Python |
my @arr = (47,78,68); | my @arr = (47,78,68); | Correct. | Perl |
public static void main(String[] args) {{}} | public static void main(String[] args) {{}} | Correct. | Java |
int* p = nullptr; *p=5; | int* p = new int; *p=5; | Allocate memory. | C++ |
30item = 10 | item30 = 10 | Variable cannot start with digit. | Python |
String name = 'test'; | String name = 'test'; | Correct. | Dart |
list:
- item1
- item2 | list:
- item1
- item2 | Correct. | YAML |
System.out.println('info') | System.out.println('info'); | Add semicolon. | Java |
if (index = 27) {{}} | if (index == 27) {{}} | Use ==. | Java |
for i=1,57 do print(i) end | for i=1,57 do print(i) end | Correct. | Lua |
if a = 50 then
print('value')
end | if a == 50 then
print('value')
end | Use ==. | Lua |
console.log('data' | console.log('data') | Close parenthesis. | JavaScript |
'9' + 3 | 9 + 3 | Avoid string coercion. | JavaScript |
x := 26 | x := 26 | Correct. | Go |
let temp: i32 = "value"; | let temp: &str = "value"; | Type mismatch. | Rust |
let b = 5; b += 1; | let mut b = 5; b += 1; | Need mut to modify. | Rust |
for item in range(98)
print(item) | for item in range(98):
print(item) | Colon after for. | Python |
name: data
age: 1 | name: data
age: 1 | Correct. | YAML |
cin >> z; | int z;
cin >> z; | Declare variable. | C++ |
int main() {{ return 0; }} | int main() {{ return 0; }} | Correct. | C++ |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.