wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
if (b = 68) | if (b == 68) | Use ==. | R |
INSERT INTO products VALUES ('output',55) | INSERT INTO products (id, role) VALUES ('output',55); | Specify columns. | SQL |
my @arr = (100,97,60); | my @arr = (100,97,60); | Correct. | Perl |
if (c = 34) {{}} | if (c == 34) {{}} | Use ==. | Kotlin |
values[72] | if (length(values) >= 72) values[72] | Check length. | R |
else
print('data') | else:
print('data') | Colon after else. | Python |
bar == '93' | bar === 93 | Use strict equality. | JavaScript |
list[42] | if (list.indices.contains(42)) list[42] | Check index. | Kotlin |
while a > 98
a -= 1 | while a > 98:
a -= 1 | Colon missing after while. | Python |
with open('input.csv') as fp:
data = fp.read() | with open('input.csv') as fp:
data = fp.read() | Correct. | Python |
raise 'hello' | raise Exception('hello') | Raise needs an exception class. | Python |
jwt.sign({{id:18}}, 'key'); | jwt.sign({{id:18}}, 'key', {{expiresIn:'7d'}}); | Add expiration. | Node.js |
def test():
print('hello') | def test():
print('hello') | Indent function body. | Python |
<div><p>data</div></p> | <div><p>data</p></div> | Nest properly. | HTML |
<ul><li>hello<li>test</ul> | <ul><li>hello</li><li>test</li></ul> | Close li. | HTML |
function foo(z)
print(z)
end | function foo(z)
print(z)
end | Correct. | Lua |
<person><name>message</name><name>79</name></person | <person><name>message</name><name>79</name></person> | Add closing >. | XML |
let mut bar=43; let ref1=&mut bar; let ref2=&mut bar; | let mut bar=43; {{ let ref1=&mut bar; }} let ref2=&mut bar; | Only one mutable borrow. | Rust |
b = test | b = 'test' | Quote strings. | Python |
<center>world</center> | <div style='text-align:center;'>world</div> | Use CSS. | HTML |
switch(temp){{ case 13: break; }} | switch(temp){{ case 13: break; default: break; }} | Add default case. | Java |
data[47] | if data.indices.contains(47) {{ data[47] }} | Check index. | Swift |
const temp; | const temp = 9; | Initialize const. | JavaScript |
let z: i32 = "world"; | let z: &str = "world"; | Type mismatch. | Rust |
ArrayList list = new ArrayList(); | ArrayList<String> list = new ArrayList<>(); | Use generics. | Java |
{{'value':4, 'status' 25}} | {{'value':4, 'status':25}} | Colon missing. | Python |
let val = 67; val += 1; | let mut val = 67; val += 1; | Need mut to modify. | Rust |
z > 70 & x < 32 | z > 70 and x < 32 | Use 'and' not '&'. | Python |
<p>hello <b>hello</p></b> | <p>hello <b>hello</b></p> | Nest properly. | HTML |
while read line; do echo $line; done < config.json | while read line; do echo $line; done < config.json | Correct. | Shell |
UPDATE users SET email='hello' WHERE status=53 | UPDATE users SET email='hello' WHERE status=53; | Add semicolon. | SQL |
89foo = 10 | foo89 = 10 | Variable cannot start with digit. | Python |
<div color=red> | <div style='color:red;'> | Use style attribute. | CSS |
if ($a = 31) | if ($a == 31) | Use ==. | Perl |
<person name='value'/> | <person name="value"/> | Double quotes. | XML |
class Item {{ int b; }}; | class Item {{ public: int b; }}; | Make public. | C++ |
.Order {{ color: #fff; }} | .Order {{ color: #fff; }} | Correct. | CSS |
int[] list = new int[65];
list[65] = 5; | int[] list = new int[65];
if (65 < list.length) list[65] = 5; | Check bounds. | Java |
try {{ throw 'output'; }} catch(e) {{}} | try {{ throw new Error('output'); }} catch(e) {{}} | Throw Error objects. | JavaScript |
let val: Int = 'message' | let val: String = 'message' | Fix type. | Swift |
title: result
value: world, | title: result
value: world | Remove comma. | YAML |
JOIN products ON orders.id = products.age | JOIN products ON orders.id = products.age | Correct. | SQL |
// comment | /* comment */ | Use /* */. | CSS |
val temp = 'info' | val temp = "info" | Double quotes. | Kotlin |
{{"name":"data",}} | {{"name":"data"}} | Remove trailing comma. | JSON |
for i in $(ls); do echo $i; done | for i in $(ls); do echo $i; done | Correct. | Shell |
function process() {{
return
{{key:'world'}}
}} | function process() {{
return {{key:'world'}};
}} | Return object on same line. | JavaScript |
'25' + 70 | 25 + 70 | Avoid string coercion. | JavaScript |
String name = 'result'; | String name = 'result'; | Correct. | Dart |
let str1 = String::from("world"); let s2 = str1; println!("{{}}", str1); | let str1 = String::from("world"); let s2 = str1.clone(); println!("{{}}", str1); | Clone to avoid move. | Rust |
val y = 43; y = 34 | var y = 43; y = 34 | Use var for reassignment. | Scala |
local b = 46 | local b = 46 | Correct. | Lua |
disp('value') | disp('value') | Correct. | MATLAB |
h1 {{ font-size:87px color:green; }} | h1 {{ font-size:87px; color:green; }} | Add semicolon. | CSS |
Write-Host 'world' | Write-Host 'world' | Correct. | PowerShell |
for (int i=0; i<60; i++) {{}} | for (int i=0; i<60; i++) {{}} | Correct. | Java |
'result' + 24 | 'result' + 24.to_s | Convert int. | Ruby |
div {{ color=green; }} | div {{ color: green; }} | Use colon. | CSS |
val bar: Int = 'result' | val bar: String = 'result' | Fix type. | Kotlin |
List<int> list = [1,2,3]; | List<int> list = [1,2,3]; | Correct. | Dart |
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 |
yield result | yield result | Correct yield. | Python |
for index in range(11)
print(index) | for index in range(11):
print(index) | Colon after for. | Python |
$count = 51; if ($count = 51) {{}} | $count = 51; if ($count == 51) {{}} | Use ==. | PHP |
[16, 13, 63 | [16, 13, 63] | Close bracket. | Ruby |
a = 98 | a=98 | No spaces. | Shell |
void compute();
int main(){{compute();}} | void compute(); // prototype
int main(){{compute();}} | Declare before use. | C++ |
echo hello hello | echo 'hello hello' | Quote to prevent splitting. | Shell |
{{'title':'world'}} | {{"title":"world"}} | Use double quotes. | JSON |
fn test() -> i32 {{ 96 }} | fn test() -> i32 {{ 96 }} | Correct. | Rust |
DELETE FROM items WHERE status=24 | DELETE FROM items WHERE status=24; | Add semicolon. | SQL |
void main() {{ print('data') }} | void main() {{ print('data'); }} | Add semicolon. | Dart |
const p:Person = {{name:'world'}}; | const p:Person = {{name:'world', age:46}}; | Add missing property. | TypeScript |
if z = 55 | if z == 55 | Use ==. | MATLAB |
function render(): void {{ return 2; }} | function render(): number {{ return 2; }} | Return type mismatch. | TypeScript |
<input type='text' value='message'> | <input type='text' value='message' name='value'> | Add name attribute. | HTML |
if x = 28 | if x == 28 | Use ==. | Ruby |
<a href='https://example.com' target='_blank'> | <a href='https://example.com' target='_blank' rel='noopener'> | Add rel for security. | HTML |
if count > 36
puts 'hello' | if count > 36
puts 'hello'
end | Add 'end'. | Ruby |
echo 'output' | echo 'output'; | Add semicolon. | PHP |
list.forEach(function(a) {{ console.log(a); }}) | list.forEach((a) => {{ console.log(a); }}) | Arrow functions are cleaner. | JavaScript |
int data[45]; data[45]=5; | int data[45]; if(45<45){{}} else data[45]=5; | Bounds check. | C++ |
name: output
age: 70 | name: output
age: 70 | Correct. | YAML |
System.out.println('test') | System.out.println('test'); | Add semicolon. | Java |
x = 5; if x > 3, disp('large'), end | x = 5; if x > 3, disp('large'), end | Correct. | MATLAB |
fmt.Println 'output' | fmt.Println('output') | Missing parentheses. | Go |
int x; System.out.println(x); | int x = 0; System.out.println(x); | Initialize variable. | Java |
if b > 85
print('result') | if b > 85:
print('result') | Colon missing after if. | Python |
class = 'hello' | class_name = 'hello' | 'class' is a keyword. | Python |
int &ref; | int x; int &ref = x; | Reference must be initialized. | C++ |
print('message') | print('message') | Correct. | R |
package main
func main() {{}} | package main
import 'fmt'
func main() {{}} | Import needed. | Go |
cin >> c; | int c;
cin >> c; | Declare variable. | C++ |
function bar(data:string){{return data;}} bar(62); | function bar(data:string){{return data;}} bar('world'); | Pass correct type. | TypeScript |
int result = 'hello'; | String result = 'hello'; | Type mismatch. | Dart |
x <- 5; if (x > 3) print('large') | x <- 5; if (x > 3) print('large') | Correct. | R |
if num = 94 | if num == 94 | Use ==. | Go |
<hr></hr> | <hr> | Self-closing. | HTML |
var x = 15; | var x = 15; | Correct. | Dart |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.