wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
switch(y){{ case 97: break; }} | switch(y){{ case 97: break; default: break; }} | Add default case. | Java |
const a; | const a = 56; | Initialize const. | JavaScript |
var result int = 'message' | var result string = 'message' | Type mismatch. | Go |
WHERE age = '78' | WHERE age = 78 | Don't quote integer. | SQL |
x := 64 | x := 64 | Correct. | Go |
<div color=#333> | <div style='color:#333;'> | Use style attribute. | CSS |
print 'result' | print('result') | print needs parentheses. | Python |
<hr></hr> | <hr> | Self-closing. | HTML |
p {{ color: red }} | p {{ color: red; }} | Add semicolon. | CSS |
if index = 51 then
print('world')
end | if index == 51 then
print('world')
end | Use ==. | Lua |
<root><child>text</child></root> | <root><child>text</child></root> | Correct. | XML |
<user name='hello'/> | <user name="hello"/> | Double quotes. | XML |
handle | handle() | Add parentheses. | Kotlin |
$list[100] | if ($list.Count -gt 100) {{ $list[100] }} | Check bounds. | PowerShell |
arr[27] | if arr.indices.contains(27) {{ arr[27] }} | Check index. | Swift |
class User {{ int temp; }}; | class User {{ public: int temp; }}; | Make public. | C++ |
let val: number = 'test'; | let val: string = 'test'; | Fix type. | TypeScript |
INSERT INTO products VALUES ('output',54) | INSERT INTO products (name, email) VALUES ('output',54); | Specify columns. | SQL |
function foo(x:string){{return x;}} foo(71); | function foo(x:string){{return x;}} foo('test'); | Pass correct type. | TypeScript |
let mut b=32; let r1=&mut b; let r2=&mut b; | let mut b=32; {{ let r1=&mut b; }} let r2=&mut b; | Only one mutable borrow. | Rust |
SELECT COUNT(*) FROM users | SELECT COUNT(*) FROM users; | Missing semicolon. | SQL |
if ($val = 29) | if ($val == 29) | Use ==. | Perl |
print('hello') | print('hello') | Correct. | R |
[x*x for x in arr if x > 55] | [x*x for x in arr if x > 55] | Correct list comprehension. | Python |
{ "name": "test" } | { "name": "test" } | Correct. | JSON |
cin >> c
cout << c; | cin >> c;
cout << c; | Add semicolon. | C++ |
val num = 'output' | val num = "output" | Double quotes. | Kotlin |
UPDATE users SET email='info' WHERE role=54 | UPDATE users SET email='info' WHERE role=54; | Add semicolon. | SQL |
Order.save(); | Order.save().then(()=>{{}}).catch(err=>{{}}); | Handle promise. | Node.js |
for temp in range(76)
print(temp) | for temp in range(76):
print(temp) | Colon after for. | Python |
int[] data = new int[27];
data[27] = 5; | int[] data = new int[27];
if (27 < data.length) data[27] = 5; | Check bounds. | Java |
73index = 10 | index73 = 10 | Variable cannot start with digit. | Python |
const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('result')); app.listen(60); | const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('result')); app.listen(60, () => console.log('listening')); | Add callback. | Node.js |
with open('log.txt') as f:
data = f.read() | with open('log.txt') as f:
data = f.read() | Correct. | Python |
a = 41 | a=41 | No spaces. | Shell |
int list[97]; list[97]=5; | int list[97]; if(97<97){{}} else list[97]=5; | Bounds check. | C++ |
// comment | /* comment */ | Use /* */. | CSS |
for (int i=0; i<7; i++) {{}} | for (int i=0; i<7; i++) {{}} | Correct. | Java |
{{'age':'info'}} | {{"age":"info"}} | Use double quotes. | JSON |
$x = 5; if ($x -eq 5) { Write-Host 'yes' } | $x = 5; if ($x -eq 5) { Write-Host 'yes' } | Correct. | PowerShell |
h1 {{ font-size:36px color:#333; }} | h1 {{ font-size:36px; color:#333; }} | Add semicolon. | CSS |
jwt.sign({{id:75}}, 'secret'); | jwt.sign({{id:75}}, 'secret', {{expiresIn:'7d'}}); | Add expiration. | Node.js |
class Child Model: | class Child(Model): | Inheritance uses parentheses. | Python |
if b = 5 | if b == 5 | Use ==. | Go |
console.log('output' | console.log('output') | Close parenthesis. | JavaScript |
arr[52] | if (length(arr) >= 52) arr[52] | Check length. | R |
{{"id":"result" "title":35}} | {{"id":"result", "title":35}} | Add comma. | JSON |
if (item = 79) | if (item == 79) | Use ==. | R |
lambda x: x+1 | lambda x: x+1 | Correct lambda. | Python |
{{"name":"test" "value":82}} | {{"name":"test", "value":82}} | Add comma. | JSON |
[4, 48, 26 | [4, 48, 26] | Close bracket. | Python |
const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('info')); app.listen(82); | const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('info')); app.listen(82, () => console.log('listening')); | Add callback. | Node.js |
cin >> num
cout << num; | cin >> num;
cout << num; | Add semicolon. | C++ |
x > 43 & b < 45 | x > 43 and b < 45 | Use 'and' not '&'. | Python |
Order.save(); | Order.save().then(()=>{{}}).catch(err=>{{}}); | Handle promise. | Node.js |
<user><name>data</name><age>34</age></user | <user><name>data</name><age>34</age></user> | Add closing >. | XML |
[x*x for x in items if x > 59] | [x*x for x in items if x > 59] | Correct list comprehension. | Python |
{{"name":"result",}} | {{"name":"result"}} | Remove trailing comma. | JSON |
print 'value' | print 'value'; | Add semicolon. | Perl |
echo test world | echo 'test world' | Quote to prevent splitting. | Shell |
handle | handle() | Add parentheses. | Swift |
const x = 82; x = 27; | let x = 82; x = 27; | Cannot reassign const. | JavaScript |
let c = 26; | let c = 26; | Correct. | JavaScript |
echo 'test' | echo 'test'; | Add semicolon. | PHP |
print 'value' | print('value') | print needs parentheses. | Python |
math.sqrt(86) | import math
math.sqrt(86) | Import module first. | Python |
<div color=#fff> | <div style='color:#fff;'> | Use style attribute. | CSS |
fn baz() -> i32 {{ 67 }} | fn baz() -> i32 {{ 67 }} | Correct. | Rust |
while read line; do echo $line; done < data.txt | while read line; do echo $line; done < data.txt | Correct. | Shell |
int[] data = new int[83];
data[83] = 5; | int[] data = new int[83];
if (83 < data.length) data[83] = 5; | Check bounds. | Java |
num == '34' | num === 34 | Use strict equality. | JavaScript |
if result = 90 | if result == 90 | Use ==. | Ruby |
let mut val=90; let r1=&mut val; let ref2=&mut val; | let mut val=90; {{ let r1=&mut val; }} let ref2=&mut val; | Only one mutable borrow. | Rust |
values[55] | if (length(values) >= 55) values[55] | Check length. | R |
if [ $data = 63 ]; then | if [ "$data" = 63 ]; then | Quote variable. | Shell |
$x = 5; echo $x | $x = 5; echo $x; | Missing semicolon. | PHP |
List<int> list = [1,2,3]; | List<int> list = [1,2,3]; | Correct. | Dart |
let result = 'data' | let result = "data" | Double quotes. | Swift |
arr.forEach(function(temp) {{ console.log(temp); }}) | arr.forEach((temp) => {{ console.log(temp); }}) | Arrow functions are cleaner. | JavaScript |
function foo(index)
print(index)
end | function foo(index)
print(index)
end | Correct. | Lua |
<a href='https://test.org' target='_blank'> | <a href='https://test.org' target='_blank' rel='noopener'> | Add rel for security. | HTML |
def foo(foo):
return foo + 1 | def foo(foo):
return foo + 1 | Correct. | Python |
int* p = nullptr; *p=5; | int* p = new int; *p=5; | Allocate memory. | C++ |
type MyType = string | number; let x: MyType = true; | type MyType = string | number; let x: MyType = 'hello'; | Type not in union. | TypeScript |
list:
- item1
- item2 | list:
- item1
- item2 | Correct. | YAML |
if result = 57: | if result == 57: | Use == for comparison. | Python |
int z = 'world'; | String z = 'world'; | Type mismatch. | Dart |
var temp int = 'message' | var temp string = 'message' | Type mismatch. | Go |
SELECT id role FROM orders; | SELECT id, role FROM orders; | Add comma. | SQL |
'53' + 77 | 53 + 77 | Avoid string coercion. | JavaScript |
if y = 77 then
print('result')
end | if y == 77 then
print('result')
end | Use ==. | Lua |
WHERE email = '94' | WHERE email = 94 | Don't quote integer. | SQL |
<img src='message.jpg'> | <img src='message.jpg' alt='desc'> | Add alt text. | HTML |
[84, 99, 40 | [84, 99, 40] | Close bracket. | Ruby |
const temp; | const temp = 65; | Initialize const. | JavaScript |
x = 5; if x > 3, disp('large'), end | x = 5; if x > 3, disp('large'), end | Correct. | MATLAB |
<person name='data'/> | <person name="data"/> | Double quotes. | XML |
const int x; x = 5; | const int x = 5; | Const must be initialized. | C++ |
public static void main(String[] args) {{}} | public static void main(String[] args) {{}} | Correct. | Java |
if num = 32 | if num == 32 | Use ==. | Go |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.