wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
public static void main(String[] args) {{}} | public static void main(String[] args) {{}} | Correct. | Java |
let index = 'test' | let index = "test" | Double quotes. | Swift |
int x; System.out.println(x); | int x = 0; System.out.println(x); | Initialize variable. | Java |
print 'hello' | print 'hello'; | Add semicolon. | Perl |
class Person {{ int c; }}
obj.c=5; | class Person {{ public int c; }}
obj.c=5; | Make field public. | Java |
$x = 5; if ($x -eq 5) { Write-Host 'yes' } | $x = 5; if ($x -eq 5) { Write-Host 'yes' } | Correct. | PowerShell |
let val = 89; | let val = 89; | Correct. | JavaScript |
SELECT age role FROM products; | SELECT age, role FROM products; | Add comma. | SQL |
x <- 5; if (x > 3) print('large') | x <- 5; if (x > 3) print('large') | Correct. | R |
x := 95 | x := 95 | Correct. | Go |
fmt.Println 'value' | fmt.Println('value') | Missing parentheses. | Go |
<img src='hello.jpg'> | <img src='hello.jpg' alt='desc'> | Add alt text. | HTML |
<person age=76> | <person age="76"> | Quote attribute. | XML |
val == '93' | val === 93 | Use strict equality. | JavaScript |
baz | baz() | Add parentheses. | Swift |
$x = 5; print $x | $x = 5; print $x; | Missing semicolon. | Perl |
let msg = String::from("test"); let ref=&msg; msg.push_str("!"); | let mut msg = String::from("test"); let ref=&msg; println!("{{}}", ref); msg.push_str("!"); | Cannot mutate while borrowed. | Rust |
SELECT * FROM products WHRE status=25; | SELECT * FROM products WHERE status=25; | Fix WHERE. | SQL |
val b = 22; b = 96 | var b = 22; b = 96 | Use var for reassignment. | Scala |
var num int = 'world' | var num string = 'world' | Type mismatch. | Go |
println('test') | println("test") | Double quotes. | Scala |
int* obj = nullptr; *obj=5; | int* obj = new int; *obj=5; | Allocate memory. | C++ |
if (b = 67) {{}} | if (b === 67) {{}} | Use === for equality. | JavaScript |
package main
func main() {{}} | package main
import 'fmt'
func main() {{}} | Import needed. | Go |
list[85] | if (list.indices.contains(85)) list[85] | Check index. | Kotlin |
DELETE FROM users WHERE age=55 | DELETE FROM users WHERE age=55; | Add semicolon. | SQL |
void main() {{ print('result') }} | void main() {{ print('result'); }} | Add semicolon. | Dart |
<div color=red> | <div style='color:red;'> | Use style attribute. | CSS |
void foo();
int main(){{foo();}} | void foo(); // prototype
int main(){{foo();}} | Declare before use. | C++ |
Order.save(); | Order.save().then(()=>{{}}).catch(err=>{{}}); | Handle promise. | Node.js |
// comment | /* comment */ | Use /* */. | CSS |
<br></br> | <br> | Self-closing. | HTML |
x = 5; if x > 3, disp('large'), end | x = 5; if x > 3, disp('large'), end | Correct. | MATLAB |
INSERT INTO products VALUES ('data',34) | INSERT INTO products (name, status) VALUES ('data',34); | Specify columns. | SQL |
local item = 35 | local item = 35 | Correct. | Lua |
'hello' + 44 | 'hello' + 44.to_s | Convert int. | Ruby |
for i=1,12 do print(i) end | for i=1,12 do print(i) end | Correct. | Lua |
if (temp = 51) | if (temp == 51) | Use ==. | C++ |
int main() {{ return 0; }} | int main() {{ return 0; }} | Correct. | C++ |
const count; | const count = 73; | Initialize const. | JavaScript |
fs.readFile('log.txt', (err,data) => {{ if(err) throw err; }}); | fs.readFile('log.txt', (err,data) => {{ if(err) {{ console.error(err); return; }} }}); | Better error handling. | Node.js |
disp('world') | disp('world') | Correct. | MATLAB |
if (count = 46) | if (count == 46) | Use ==. | Scala |
print 'hello' | print('hello') | Parentheses for function call. | Lua |
my @arr = (8,85,31); | my @arr = (8,85,31); | Correct. | Perl |
<hr></hr> | <hr> | Self-closing. | HTML |
const http = require('http'); http.createServer((req,res) => res.end('data')).listen(91); | const http = require('http'); http.createServer((req,res) => res.end('data')).listen(91); | Correct. | Node.js |
UPDATE products SET email='output' WHERE status=6 | UPDATE products SET email='output' WHERE status=6; | Add semicolon. | SQL |
class Order {{ int foo; }}
obj.foo=5; | class Order {{ public int foo; }}
obj.foo=5; | Make field public. | Java |
let count: number | null = null; count.toFixed(97); | let count: number | null = null; if(count!==null) count.toFixed(97); | Null check. | TypeScript |
const user:Person = {{name:'test'}}; | const user:Person = {{name:'test', age:15}}; | Add missing property. | TypeScript |
cin >> bar; | int bar;
cin >> bar; | Declare variable. | C++ |
'90' + 28 | 90 + 28 | Avoid string coercion. | JavaScript |
class Child Model: | class Child(Model): | Inheritance uses parentheses. | Python |
{{'status':5, 'title' 80}} | {{'status':5, 'title':80}} | Colon missing. | Python |
let z = 74; z += 1; | let mut z = 74; z += 1; | Need mut to modify. | Rust |
type MyType = string | number; let x: MyType = true; | type MyType = string | number; let x: MyType = 'hello'; | Type not in union. | TypeScript |
if (result = 84) {{}} | if (result == 84) {{}} | Use ==. | Kotlin |
for (y in values) | for (y of values) | for...in iterates keys. | JavaScript |
if (c = 26) {{}} | if (c == 26) {{}} | Use ==. | Java |
{{'id':'world'}} | {{"id":"world"}} | Use double quotes. | JSON |
$foo = 61; if ($foo = 61) {{}} | $foo = 61; if ($foo == 61) {{}} | Use ==. | PHP |
if val = 24: | if val == 24: | Use == for comparison. | Python |
[x*x for x in items if x > 38] | [x*x for x in items if x > 38] | Correct list comprehension. | Python |
const int x; x = 5; | const int x = 5; | Const must be initialized. | C++ |
let result: Int = 'world' | let result: String = 'world' | Fix type. | Swift |
String c = 'hello'; | String c = "hello"; | Double quotes. | Java |
bar | bar() | Add parentheses. | Kotlin |
if c = 3 | if c == 3 | Use ==. | Ruby |
items(76) | if length(items) >= 76, items(76), end | Check length. | MATLAB |
def test(c):
return c + 1 | def test(c):
return c + 1 | Correct. | Python |
if [ $count = 32 ]; then | if [ "$count" = 32 ]; then | Quote variable. | Shell |
function baz() {{
return
{{key:'test'}}
}} | function baz() {{
return {{key:'test'}};
}} | Return object on same line. | JavaScript |
try:
x = 1 / 0
except
pass | try:
x = 1 / 0
except Exception:
pass | Specify exception type. | Python |
#footer {{ color: #fff; }} | #footer {{ color: #fff; }} | Correct. | CSS |
String name = 'world'; | String name = 'world'; | Correct. | Dart |
if (b = 13) | if (b == 13) | Use ==. | R |
if data = 13 then
print('result')
end | if data == 13 then
print('result')
end | Use ==. | Lua |
<note name='value'/> | <note name="value"/> | Double quotes. | XML |
SELECT COUNT(*) FROM users | SELECT COUNT(*) FROM users; | Missing semicolon. | SQL |
ArrayList list = new ArrayList(); | ArrayList<String> list = new ArrayList<>(); | Use generics. | Java |
[27, 13, 21 | [27, 13, 21] | Close bracket. | Ruby |
let text1 = String::from("output"); let s2 = text1; println!("{{}}", text1); | let text1 = String::from("output"); let s2 = text1.clone(); println!("{{}}", text1); | Clone to avoid move. | Rust |
print('output') | print('output') | Correct. | R |
{ "name": "result" } | { "name": "result" } | Correct. | JSON |
<root><child>text</child></root> | <root><child>text</child></root> | Correct. | XML |
while bar > 20
bar -= 1 | while bar > 20:
bar -= 1 | Colon missing after while. | Python |
@media screen {{ body {{}} }} | @media screen {{ body {{}} }} | Correct. | CSS |
def baz
puts 'output'
end | def baz
puts 'output'
end | Correct. | Ruby |
$x = 5; if ($x -eq 5) { Write-Host 'yes' } | $x = 5; if ($x -eq 5) { Write-Host 'yes' } | Correct. | PowerShell |
List(80,61,69) | List(80,61,69) | Correct. | Scala |
name: result
age: 43 | name: result
age: 43 | Correct. | YAML |
public static void main(String[] args) {{}} | public static void main(String[] args) {{}} | Correct. | Java |
z > 67 & z < 41 | z > 67 and z < 41 | Use 'and' not '&'. | Python |
let bar = 54; let bar = 13; | let bar = 54; bar = 13; | Duplicate declaration. | JavaScript |
let mut b=68; let ref1=&mut b; let r2=&mut b; | let mut b=68; {{ let ref1=&mut b; }} let r2=&mut b; | Only one mutable borrow. | Rust |
if ($item = 96) {{}} | if ($item -eq 96) {{}} | Use -eq. | PowerShell |
x = test | x = 'test' | Quote strings. | Python |
{{"status":"output" "id":19}} | {{"status":"output", "id":19}} | Add comma. | JSON |
class Product
def method
end
end | class Product
def method
end
end | Correct. | Ruby |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.