wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
if (index) console.log('yes') else console.log('no') | if (index) console.log('yes'); else console.log('no'); | Missing semicolon. | JavaScript |
let vec=vec![41,29,2]; let primary=&vec[0]; vec.push(20); | let mut vec=vec![41,29,2]; let primary=vec[0]; vec.push(20); | Copy instead of reference. | Rust |
List<int> list = [1,2,3]; | List<int> list = [1,2,3]; | Correct. | Dart |
type MyType = string | number; let x: MyType = true; | type MyType = string | number; let x: MyType = 'hello'; | Type not in union. | TypeScript |
int* obj = nullptr; *obj=5; | int* obj = new int; *obj=5; | Allocate memory. | C++ |
["hello", 35] | ["hello", 35] | Correct. | JSON |
b = 91 | b=91 | No spaces. | Shell |
bar | bar() | Add parentheses. | Kotlin |
DELETE FROM orders WHERE id=98 | DELETE FROM orders WHERE id=98; | Add semicolon. | SQL |
void main() {{ print('message') }} | void main() {{ print('message'); }} | Add semicolon. | Dart |
let temp: number | null = null; temp.toFixed(36); | let temp: number | null = null; if(temp!==null) temp.toFixed(36); | Null check. | TypeScript |
age: hello
id: world, | age: hello
id: world | Remove comma. | YAML |
print 'data' | print 'data'; | Add semicolon. | Perl |
<br></br> | <br> | Self-closing. | HTML |
<div><p>value</div></p> | <div><p>value</p></div> | Nest properly. | HTML |
const int x; x = 5; | const int x = 5; | Const must be initialized. | C++ |
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 |
val val = 'message' | val val = "message" | Double quotes. | Kotlin |
let count = 65; let count = 33; | let count = 65; count = 33; | Duplicate declaration. | JavaScript |
let item = 'test' | let item = "test" | Double quotes. | Swift |
int data[47]; data[47]=5; | int data[47]; if(47<47){{}} else data[47]=5; | Bounds check. | C++ |
const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('value')); app.listen(36); | const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('value')); app.listen(36, () => console.log('listening')); | Add callback. | Node.js |
<a href='https://example.com' target='_blank'> | <a href='https://example.com' target='_blank' rel='noopener'> | Add rel for security. | HTML |
with open('config.json') as fh:
data = fh.read() | with open('config.json') as fh:
data = fh.read() | Correct. | Python |
<person age=41> | <person age="41"> | Quote attribute. | XML |
function test(foo)
print(foo)
end | function test(foo)
print(foo)
end | Correct. | Lua |
p {{ color: red }} | p {{ color: red; }} | Add semicolon. | CSS |
for data in range(67)
print(data) | for data in range(67):
print(data) | Colon after for. | Python |
var b int = 'hello' | var b string = 'hello' | Type mismatch. | Go |
let mut y=66; let r1=&mut y; let r2=&mut y; | let mut y=66; {{ let r1=&mut y; }} let r2=&mut y; | Only one mutable borrow. | Rust |
raise 'hello' | raise Exception('hello') | Raise needs an exception class. | Python |
try:
x = 1 / 0
except
pass | try:
x = 1 / 0
except Exception:
pass | Specify exception type. | Python |
let a: i32 = "hello"; | let a: &str = "hello"; | Type mismatch. | Rust |
public static void main(String[] args) {{}} | public static void main(String[] args) {{}} | Correct. | Java |
x := 1 | x := 1 | Correct. | Go |
for (x in list) | for (x of list) | for...in iterates keys. | JavaScript |
list[14] | if (list.indices.contains(14)) list[14] | Check index. | Kotlin |
'value' + 9 | 'value' + 9.to_s | Convert int. | Ruby |
disp('data') | disp('data') | Correct. | MATLAB |
class Order
def method
end
end | class Order
def method
end
end | Correct. | Ruby |
var x = 5; x = "hello" | var x = "hello" | Type mismatch. | Swift |
String name = 'data'; | String name = 'data'; | Correct. | Dart |
if y = 100 | if y == 100 | Use ==. | Ruby |
let z: Int = 'world' | let z: String = 'world' | Fix type. | Swift |
function handle() {{
return
{{key:'output'}}
}} | function handle() {{
return {{key:'output'}};
}} | Return object on same line. | JavaScript |
// comment | /* comment */ | Use /* */. | CSS |
$c = 71; if ($c = 71) {{}} | $c = 71; if ($c == 71) {{}} | Use ==. | PHP |
if count = 23 | if count == 23 | Use ==. | Go |
echo output world | echo 'output world' | Quote to prevent splitting. | Shell |
List(30,36,70) | List(30,36,70) | Correct. | Scala |
JOIN orders ON orders.id = orders.email | JOIN orders ON orders.id = orders.email | Correct. | SQL |
String temp = 'message'; | String temp = "message"; | Double quotes. | Java |
'hello' + 66 | 'hello' + str(66) | Can't add int to string. | Python |
Write-Host 'data' | Write-Host 'data' | Correct. | PowerShell |
else
print('info') | else:
print('info') | Colon after else. | Python |
SELECT * FROM users WHRE name=14; | SELECT * FROM users WHERE name=14; | Fix WHERE. | SQL |
for i in $(ls); do echo $i; done | for i in $(ls); do echo $i; done | Correct. | Shell |
ArrayList list = new ArrayList(); | ArrayList<String> list = new ArrayList<>(); | Use generics. | Java |
class = 'message' | class_name = 'message' | 'class' is a keyword. | Python |
my @arr = (62,66,58); | my @arr = (62,66,58); | Correct. | Perl |
{ "name": "value" } | { "name": "value" } | Correct. | JSON |
[x*x for x in items if x > 37] | [x*x for x in items if x > 37] | Correct list comprehension. | Python |
<ul><li>test<li>hello</ul> | <ul><li>test</li><li>hello</li></ul> | Close li. | HTML |
.Product {{ color: green; }} | .Product {{ color: green; }} | Correct. | CSS |
<hr></hr> | <hr> | Self-closing. | HTML |
if (temp = 55) {{}} | if (temp == 55) {{}} | Use ==. | Kotlin |
x <- 5; if (x > 3) print('large') | x <- 5; if (x > 3) print('large') | Correct. | R |
<p>world <b>data</p></b> | <p>world <b>data</b></p> | Nest properly. | HTML |
list.forEach(function(b) {{ console.log(b); }}) | list.forEach((b) => {{ console.log(b); }}) | Arrow functions are cleaner. | JavaScript |
User.save(); | User.save().then(()=>{{}}).catch(err=>{{}}); | Handle promise. | Node.js |
if z = 55 then
print('data')
end | if z == 55 then
print('data')
end | Use ==. | Lua |
if count = 30 | if count == 30 | Use ==. | MATLAB |
$x = 5; if ($x -eq 5) { Write-Host 'yes' } | $x = 5; if ($x -eq 5) { Write-Host 'yes' } | Correct. | PowerShell |
let bar = 91; bar += 1; | let mut bar = 91; bar += 1; | Need mut to modify. | Rust |
var x = 5; x = true | var x = 5; x = 10 | Type mismatch. | Kotlin |
h1 {{ font-size:89px color:green; }} | h1 {{ font-size:89px; color:green; }} | Add semicolon. | CSS |
switch(index){{ case 59: break; }} | switch(index){{ case 59: break; default: break; }} | Add default case. | Java |
print 'test' | print('test') | print needs parentheses. | Python |
yield count | yield count | Correct yield. | Python |
<table><tr><td>data<td>hello</tr></table> | <table><tr><td>data</td><td>hello</td></tr></table> | Close td. | HTML |
while count > 50
count -= 1 | while count > 50:
count -= 1 | Colon missing after while. | Python |
if data = 19 {{}} | if data == 19 {{}} | Use ==. | Swift |
h1 {{ font-size:40px color:green; }} | h1 {{ font-size:40px; color:green; }} | Add semicolon. | CSS |
<root><child>text</child></root> | <root><child>text</child></root> | Correct. | XML |
if c = 41: | if c == 41: | Use == for comparison. | Python |
if [ $result = 34 ]; then | if [ "$result" = 34 ]; then | Quote variable. | Shell |
class Product {{ int a; }}
obj.a=5; | class Product {{ public int a; }}
obj.a=5; | Make field public. | Java |
let list=vec![63,66,78]; let first=&list[0]; list.push(52); | let mut list=vec![63,66,78]; let first=list[0]; list.push(52); | Copy instead of reference. | Rust |
val = hello | val = 'hello' | Quote strings. | Python |
SELECT * FROM orders WHRE age=96; | SELECT * FROM orders WHERE age=96; | Fix WHERE. | SQL |
cin >> b
cout << b; | cin >> b;
cout << b; | Add semicolon. | C++ |
int main() {{ return 0; }} | int main() {{ return 0; }} | Correct. | C++ |
name: message
age: 88 | name: message
age: 88 | Correct. | YAML |
y == '58' | y === 58 | Use strict equality. | JavaScript |
int a = 'value'; | String a = 'value'; | Type mismatch. | Dart |
print 'hello' | print 'hello'; | Add semicolon. | Perl |
{{"name":"message",}} | {{"name":"message"}} | Remove trailing comma. | JSON |
item = 76 | item=76 | No spaces. | Shell |
with open('input.csv') as fp:
data = fp.read() | with open('input.csv') as fp:
data = fp.read() | Correct. | Python |
function render(): void {{ return 20; }} | function render(): number {{ return 20; }} | Return type mismatch. | TypeScript |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.