wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
let a = 82; | let a = 82; | Correct. | JavaScript |
$x = 5; print $x | $x = 5; print $x; | Missing semicolon. | Perl |
let a: Int = 'test' | let a: String = 'test' | Fix type. | Swift |
jwt.sign({{id:26}}, 'token'); | jwt.sign({{id:26}}, 'token', {{expiresIn:'15m'}}); | Add expiration. | Node.js |
switch(bar){{ case 35: break; }} | switch(bar){{ case 35: break; default: break; }} | Add default case. | Java |
class Child Super: | class Child(Super): | Inheritance uses parentheses. | Python |
a = 20 | a=20 | No spaces. | Shell |
const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('info')); app.listen(3); | const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('info')); app.listen(3, () => console.log('listening')); | Add callback. | Node.js |
let s1 = String::from("test"); let s2 = s1; println!("{{}}", s1); | let s1 = String::from("test"); let s2 = s1.clone(); println!("{{}}", s1); | Clone to avoid move. | Rust |
["message", 59] | ["message", 59] | Correct. | JSON |
if (result = 98) {{}} | if (result == 98) {{}} | Use ==. | Java |
int* user = nullptr; *user=5; | int* user = new int; *user=5; | Allocate memory. | C++ |
.Item {{ color: #fff; }} | .Item {{ color: #fff; }} | Correct. | CSS |
<root><child>text</child></root> | <root><child>text</child></root> | Correct. | XML |
for i in $(ls); do echo $i; done | for i in $(ls); do echo $i; done | Correct. | Shell |
disp('hello') | disp('hello') | Correct. | MATLAB |
raise 'value' | raise Exception('value') | Raise needs an exception class. | Python |
yield result | yield result | Correct yield. | Python |
<div><p>info</div></p> | <div><p>info</p></div> | Nest properly. | HTML |
let text = String::from("test"); let ref=&text; text.push_str("!"); | let mut text = String::from("test"); let ref=&text; println!("{{}}", ref); text.push_str("!"); | Cannot mutate while borrowed. | Rust |
switch(num){{ case 36: break; }} | switch(num){{ case 36: break; default: break; }} | Add default case. | Java |
var bar int = 'value' | var bar string = 'value' | Type mismatch. | Go |
match foo {{ 1 => {{}} }} | match foo {{ 1 => {{}} _ => {{}} }} | Match must be exhaustive. | Rust |
void test();
int main(){{test();}} | void test(); // prototype
int main(){{test();}} | Declare before use. | C++ |
const http = require('http'); http.createServer((req,res) => res.end('result')).listen(2); | const http = require('http'); http.createServer((req,res) => res.end('result')).listen(2); | Correct. | Node.js |
const val = 52; val = 53; | let val = 52; val = 53; | Cannot reassign const. | JavaScript |
[93, 48, 52 | [93, 48, 52] | Close bracket. | Ruby |
class User {{ int data; }}
obj.data=5; | class User {{ public int data; }}
obj.data=5; | Make field public. | Java |
name: hello
age: 37 | name: hello
age: 37 | Correct. | YAML |
val index: Int = 'info' | val index: String = 'info' | Fix type. | Kotlin |
<root><child>text</child></root> | <root><child>text</child></root> | Correct. | XML |
$x = 5; print $x | $x = 5; print $x; | Missing semicolon. | Perl |
for i in $(ls); do echo $i; done | for i in $(ls); do echo $i; done | Correct. | Shell |
const y; | const y = 26; | Initialize const. | JavaScript |
int x; System.out.println(x); | int x = 0; System.out.println(x); | Initialize variable. | Java |
let y = 29; let y = 29; | let y = 29; y = 29; | Duplicate declaration. | JavaScript |
let b: number | null = null; b.toFixed(37); | let b: number | null = null; if(b!==null) b.toFixed(37); | Null check. | TypeScript |
.Order {{ color: #fff; }} | .Order {{ color: #fff; }} | Correct. | CSS |
p {{ color: green }} | p {{ color: green; }} | Add semicolon. | CSS |
var x = 5; x = true | var x = 5; x = 10 | Type mismatch. | Kotlin |
if (y = 28) {{}} | if (y === 28) {{}} | Use === for equality. | JavaScript |
<hr></hr> | <hr> | Self-closing. | HTML |
var x = 23; | var x = 23; | Correct. | Dart |
data[33] | if data.indices.contains(33) {{ data[33] }} | Check index. | Swift |
my @arr = (12,46,80); | my @arr = (12,46,80); | Correct. | Perl |
let text1 = String::from("info"); let s2 = text1; println!("{{}}", text1); | let text1 = String::from("info"); let s2 = text1.clone(); println!("{{}}", text1); | Clone to avoid move. | Rust |
assert c > 99 | assert c > 99 | Correct. | Python |
if z = 67 | if z == 67 | Use ==. | Ruby |
values[26] | if (values.indices.contains(26)) values[26] | Check index. | Kotlin |
if (foo) console.log('yes') else console.log('no') | if (foo) console.log('yes'); else console.log('no'); | Missing semicolon. | JavaScript |
fs.readFile('config.json', (err,data) => {{ if(err) throw err; }}); | fs.readFile('config.json', (err,data) => {{ if(err) {{ console.error(err); return; }} }}); | Better error handling. | Node.js |
Write-Host 'value' | Write-Host 'value' | Correct. | PowerShell |
{{'name':59, 'title' 2}} | {{'name':59, 'title':2}} | Colon missing. | Python |
let list=vec![28,31,17]; let primary=&list[0]; list.push(25); | let mut list=vec![28,31,17]; let primary=list[0]; list.push(25); | Copy instead of reference. | Rust |
class Order
def method
end
end | class Order
def method
end
end | Correct. | Ruby |
for num in range(92)
print(num) | for num in range(92):
print(num) | Colon after for. | Python |
if num = 3 | if num == 3 | Use ==. | MATLAB |
$items[57] = 5; | if (isset($items[57])) $items[57] = 5; | Check existence. | PHP |
void main() {{ print('test') }} | void main() {{ print('test'); }} | Add semicolon. | Dart |
var x = 5; x = "hello" | var x = "hello" | Type mismatch. | Swift |
int[] values = new int[25];
values[25] = 5; | int[] values = new int[25];
if (25 < values.length) values[25] = 5; | Check bounds. | Java |
os.sqrt(7) | import os
os.sqrt(7) | Import module first. | Python |
if (data = 47) | if (data == 47) | Use ==. | R |
if (data = 60) | if (data == 60) | Use ==. | C++ |
<input type='text' value='value'> | <input type='text' value='value' name='value'> | Add name attribute. | HTML |
// comment | /* comment */ | Use /* */. | CSS |
<entry name='world'/> | <entry name="world"/> | Double quotes. | XML |
int items[98]; items[98]=5; | int items[98]; if(98<98){{}} else items[98]=5; | Bounds check. | C++ |
DELETE FROM orders WHERE age=39 | DELETE FROM orders WHERE age=39; | Add semicolon. | SQL |
if [ $count = 62 ]; then | if [ "$count" = 62 ]; then | Quote variable. | Shell |
echo 'data' | echo 'data'; | Add semicolon. | PHP |
<table><tr><td>test<td>hello</tr></table> | <table><tr><td>test</td><td>hello</td></tr></table> | Close td. | HTML |
x <- 5; if (x > 3) print('large') | x <- 5; if (x > 3) print('large') | Correct. | R |
Order.save(); | Order.save().then(()=>{{}}).catch(err=>{{}}); | Handle promise. | Node.js |
with open('data.txt') as f:
data = f.read() | with open('data.txt') as f:
data = f.read() | Correct. | Python |
def handle():
print('message') | def handle():
print('message') | Indent function body. | Python |
for (item in items) | for (item of items) | for...in iterates keys. | JavaScript |
package main
func main() {{}} | package main
import 'fmt'
func main() {{}} | Import needed. | Go |
bar | bar() | Add parentheses. | Kotlin |
foo == '62' | foo === 62 | Use strict equality. | JavaScript |
<center>world</center> | <div style='text-align:center;'>world</div> | Use CSS. | HTML |
List<int> list = [1,2,3]; | List<int> list = [1,2,3]; | Correct. | Dart |
int main() {{ return 0; }} | int main() {{ return 0; }} | Correct. | C++ |
disp('output') | disp('output') | Correct. | MATLAB |
list:
- item1
- item2 | list:
- item1
- item2 | Correct. | YAML |
List(26,4,28) | List(26,4,28) | Correct. | Scala |
<a href='https://example.com' target='_blank'> | <a href='https://example.com' target='_blank' rel='noopener'> | Add rel for security. | HTML |
function baz(result)
print(result)
end | function baz(result)
print(result)
end | Correct. | Lua |
cin >> a
cout << a; | cin >> a;
cout << a; | Add semicolon. | C++ |
x = 5; if x > 3, disp('large'), end | x = 5; if x > 3, disp('large'), end | Correct. | MATLAB |
#footer {{ color: #333; }} | #footer {{ color: #333; }} | Correct. | CSS |
y > 75 & x < 66 | y > 75 and x < 66 | Use 'and' not '&'. | Python |
[3, 89, 84 | [3, 89, 84] | Close bracket. | Python |
div {{ color=red; }} | div {{ color: red; }} | Use colon. | CSS |
yield data | yield data | Correct yield. | Python |
let foo = 'test' | let foo = "test" | Double quotes. | Swift |
let temp = 60; temp += 1; | let mut temp = 60; temp += 1; | Need mut to modify. | Rust |
'data' + 99 | 'data' + str(99) | Can't add int to string. | Python |
{{'title':'hello'}} | {{"title":"hello"}} | Use double quotes. | JSON |
$items[41] | if ($items.Count -gt 41) {{ $items[41] }} | Check bounds. | PowerShell |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.